Skip to content

Commit

Permalink
fix(cli): no conflict in --ignore and --only
Browse files Browse the repository at this point in the history
  • Loading branch information
hasundue committed Dec 5, 2023
1 parent 379f735 commit 97db9cf
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 10 deletions.
8 changes: 2 additions & 6 deletions cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,16 +26,12 @@ const main = new Command()
.example("Target all .ts files", "molt ./**/*.ts")
.option("--import-map <file:string>", "Specify import map file")
.example("Specify an import map", "molt mod.ts --import-map deno.json")
.option("--ignore=<deps:string[]>", "Ignore dependencies", {
conflicts: ["only"],
})
.option("--ignore=<deps:string[]>", "Ignore dependencies")
.example(
"Ignore specified dependencies",
"molt deps.ts --ignore=deno_graph,node_emoji",
)
.option("--only=<deps:string[]>", "Check specified dependencies", {
conflicts: ["ignore"],
})
.option("--only=<deps:string[]>", "Check specified dependencies")
.example("Check deno_std only", "molt deps.ts --only deno.land/std")
.option("-w, --write", "Write changes to local files", {
conflicts: ["commit"],
Expand Down
2 changes: 2 additions & 0 deletions test/integration/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,8 @@ test(`molt ${dir}/multiple_imports.ts --ignore=deno_graph,node-emoji`);
test(`molt ${dir}/multiple_imports.ts --only deno.land/std`);
test(`molt ${dir}/multiple_imports.ts --only=deno.land/std,deno_graph`);

test(`molt ${dir}/multiple_imports.ts --only deno.land --ignore deno_graph`);

test(`molt ${dir}/multiple_modules/mod.ts --write`);
test(
`molt ${dir}/multiple_modules/mod.ts --write --summary title.txt --report body.md`,
Expand Down
19 changes: 15 additions & 4 deletions test/snapshots/cli.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ Options:
-h, --help - Show this help.
-v, --version - Print version info.
--import-map <file> - Specify import map file
--ignore <deps> - Ignore dependencies (Conflicts: --only)
--only <deps> - Check specified dependencies (Conflicts: --ignore)
--ignore <deps> - Ignore dependencies
--only <deps> - Check specified dependencies
-w, --write - Write changes to local files (Conflicts: --commit)
-c, --commit - Commit changes to local git repository (Conflicts: --write)
--pre-commit <tasks> - Run tasks before each commit (Depends: --commit)
Expand Down Expand Up @@ -54,8 +54,8 @@ Options:
-h, --help - Show this help.
-v, --version - Print version info.
--import-map <file> - Specify import map file
--ignore <deps> - Ignore dependencies (Conflicts: --only)
--only <deps> - Check specified dependencies (Conflicts: --ignore)
--ignore <deps> - Ignore dependencies
--only <deps> - Check specified dependencies
-w, --write - Write changes to local files (Conflicts: --commit)
-c, --commit - Commit changes to local git repository (Conflicts: --write)
--pre-commit <tasks> - Run tasks before each commit (Depends: --commit)
Expand Down Expand Up @@ -204,6 +204,17 @@ snapshot[`molt test/data/multiple_imports.ts --only=deno.land/std,deno_graph 2`]
"
`;
snapshot[`molt test/data/multiple_imports.ts --only deno.land --ignore deno_graph 1`] = `
"📦 deno.land/std 0.200.0 => 123.456.789
test/data/multiple_imports.ts 0.200.0
"
`;
snapshot[`molt test/data/multiple_imports.ts --only deno.land --ignore deno_graph 2`] = `
"Checking for updates
"
`;
snapshot[`molt test/data/multiple_modules/mod.ts --write 1`] = `
"📦 deno.land/std 0.200.0 => 123.456.789
test/data/multiple_modules/lib.ts 0.200.0
Expand Down

0 comments on commit 97db9cf

Please sign in to comment.