summaryrefslogtreecommitdiff
path: root/cli/main.rs
diff options
context:
space:
mode:
authorBartek IwaƄczuk <biwanczuk@gmail.com>2022-10-25 18:20:07 +0200
committerGitHub <noreply@github.com>2022-10-25 18:20:07 +0200
commit9835b095e56bdfc2b195b2c4741631b78a759115 (patch)
tree1fa8ee44cdc374d48c2307c1bd35085af74ec85b /cli/main.rs
parent10c3c0ee5733cfa5cf4c2825c6a8fce9f05060aa (diff)
fix(npm): add support for npm packages in lock files (#15938)
This commit adds support for npm packages in the lock file.
Diffstat (limited to 'cli/main.rs')
-rw-r--r--cli/main.rs16
1 files changed, 11 insertions, 5 deletions
diff --git a/cli/main.rs b/cli/main.rs
index 23f073a7d..1fb942963 100644
--- a/cli/main.rs
+++ b/cli/main.rs
@@ -1060,16 +1060,22 @@ fn unwrap_or_exit<T>(result: Result<T, AnyError>) -> T {
match result {
Ok(value) => value,
Err(error) => {
- let error_string = match error.downcast_ref::<JsError>() {
- Some(e) => format_js_error(e),
- None => format!("{:?}", error),
- };
+ let mut error_string = format!("{:?}", error);
+ let mut error_code = 1;
+
+ if let Some(e) = error.downcast_ref::<JsError>() {
+ error_string = format_js_error(e);
+ } else if let Some(e) = error.downcast_ref::<lockfile::LockfileError>() {
+ error_string = e.to_string();
+ error_code = 10;
+ }
+
eprintln!(
"{}: {}",
colors::red_bold("error"),
error_string.trim_start_matches("error: ")
);
- std::process::exit(1);
+ std::process::exit(error_code);
}
}
}