Skip to content

Commit

Permalink
chore(cli): --save-dev with --save-prod implies as dev
Browse files Browse the repository at this point in the history
  • Loading branch information
await-ovo committed Nov 23, 2023
1 parent c62a631 commit 75315ef
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion crates/cli/src/cli_args/add.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,11 @@ impl AddDependencyOptions {
/// Whether to add entry to `"dependencies"`.
///
/// **NOTE:** no `--save-*` flags implies save as prod.
/// `--save-prod` with `--save-dev` implies save as dev.
#[inline(always)]
fn save_prod(&self) -> bool {
let &AddDependencyOptions { save_prod, save_dev, save_optional, save_peer } = self;
save_prod || (!save_dev && !save_optional && !save_peer)
(save_prod && !save_dev) || (!save_dev && !save_optional && !save_peer)
}

/// Whether to add entry to `"devDependencies"`.
Expand Down Expand Up @@ -201,5 +202,16 @@ mod tests {
}),
[Optional, Peer]
);

// --save-dev --save-prod -> dev
assert_eq!(
create_list(AddDependencyOptions {
save_prod: true,
save_dev: true,
save_optional: false,
save_peer: false
}),
[Dev]
);
}
}

0 comments on commit 75315ef

Please sign in to comment.