Skip to content

Commit adb6dcb

Browse files
committed
remove --frozen add n ci
1 parent bebb0ad commit adb6dcb

File tree

4 files changed

+26
-33
lines changed

4 files changed

+26
-33
lines changed

.vscode/settings.json

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,3 @@
11
{
2-
"rust-analyzer.linkedProjects": [
3-
"./ni/Cargo.toml",
4-
"./ni/Cargo.toml",
5-
"./ni/Cargo.toml",
6-
"./ni/Cargo.toml",
7-
"./ni/Cargo.toml",
8-
"./ni/Cargo.toml"
9-
],
102
"cSpell.words": ["popen"]
113
}

Cargo.lock

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ n i react
4141
```
4242

4343
```bash
44-
# Ready
44+
# Ready
4545
n i react -D
4646
# npm i react -D
4747
# yarn add react -D
@@ -50,7 +50,7 @@ n i react -D
5050

5151
```bash
5252
# Ready ✅
53-
n i --frozen
53+
n ci
5454
# npm ci
5555
# yarn install --frozen-lockfile (Yarn 1)
5656
# pnpm install --frozen-lockfile

src/main.rs

Lines changed: 20 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use clap::{value_parser, Arg, ArgAction, Command};
1+
use clap::{Arg, ArgAction, Command};
22
use serde_json::Value;
33
use std::fs;
44
use std::io::{BufRead, BufReader};
@@ -18,18 +18,13 @@ fn main() {
1818
println!("👏 Package manage tool is {} , the version is {}", p, v);
1919
let matches = Command::new("n")
2020
.subcommand(
21-
Command::new("i")
22-
.about("Install operations")
23-
.arg(
24-
Arg::new("frozen")
25-
.long("frozen")
26-
.exclusive(true)
27-
.default_missing_value("true")
28-
.num_args(0..=1)
29-
.value_parser(value_parser!(bool)),
30-
)
31-
.arg(Arg::new("package").required(false)),
21+
Command::new("i").about("Install operations").arg(
22+
Arg::new("package")
23+
.required(false)
24+
.action(ArgAction::Append),
25+
),
3226
)
27+
.subcommand(Command::new("ci"))
3328
.subcommand(
3429
Command::new("r")
3530
.about("Running script")
@@ -45,18 +40,24 @@ fn main() {
4540
// Then you can check which subcommand was used
4641
match matches.subcommand() {
4742
Some(("i", i_matches)) => {
48-
if let Some(frozen) = i_matches.get_one::<bool>("frozen") {
49-
if *frozen {
50-
run_install_command(p, vec!["install", "--frozen-lockfile"])
51-
} else {
52-
run_install_command(p, vec!["install"])
53-
}
54-
} else if let Some(package) = i_matches.get_one::<String>("package") {
43+
if let Some(package) = i_matches.get_one::<String>("package") {
5544
run_install_command(p, vec!["install", package])
5645
} else {
5746
run_install_command(p, vec!["install"])
5847
}
5948
}
49+
Some(("ci", _ci_matches)) => match p.as_str() {
50+
"npm" => {
51+
run_install_command(p, vec!["ci"]);
52+
}
53+
"pnpm" => {
54+
run_install_command(p, vec!["install", "--frozen-lockfile"]);
55+
}
56+
"yarn" => {
57+
run_install_command(p, vec!["install", "--frozen-lockfile"]);
58+
}
59+
_ => {}
60+
},
6061
Some(("r", r_matches)) => match r_matches.get_one::<String>("script") {
6162
Some(script) => {
6263
run_install_command(p, vec![script]);

0 commit comments

Comments
 (0)