Skip to content

Commit

Permalink
fix: Match npm install short name.
Browse files Browse the repository at this point in the history
Signed-off-by: The1111mp <The1111mp@outlook.com>
  • Loading branch information
1111mp committed Oct 25, 2023
1 parent 0cf143c commit 2471c47
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/run/npm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ use crate::{

lazy_static! {
static ref INSTALL: OsString = OsString::from("install");
static ref SHORT_INSTALL: OsString = OsString::from("i");
static ref UNINSTALL: OsString = OsString::from("uninstall");
static ref GLOBAL: OsString = OsString::from("--global");
static ref SHORT_GLOBAL: OsString = OsString::from("-g");
Expand All @@ -30,7 +31,6 @@ lazy_static! {

pub(super) fn command(exe: &OsStr, args: &[OsString]) -> Result<ExitStatus, String> {
let is_global = args.contains(&SHORT_GLOBAL) || args.contains(&GLOBAL);
let is_global_install = is_global && args.contains(&INSTALL);
let is_global_uninstall = is_global && args.contains(&UNINSTALL);

// for npm uninstall -g packages
Expand All @@ -49,6 +49,8 @@ pub(super) fn command(exe: &OsStr, args: &[OsString]) -> Result<ExitStatus, Stri
match child {
Ok(status) => {
if status.success() {
let is_global_install =
is_global && (args.contains(&INSTALL) || args.contains(&SHORT_INSTALL));
// npm install -g packages
if is_global_install {
global_install_packages(args);
Expand Down

0 comments on commit 2471c47

Please sign in to comment.