feat(cli): allow comma-separated packages in --major/--minor/--patch … · changesets/changesets@fd7724a · GitHub
Skip to content

Commit fd7724a

Browse files
youdie006bluwy
andauthored
feat(cli): allow comma-separated packages in --major/--minor/--patch (#2135)
* feat(cli): allow comma-separated packages in --major/--minor/--patch changeset add --minor pkg1,pkg2 now expands to per-package entries, equivalent to --minor pkg1 --minor pkg2. Whitespace is trimmed and empty entries dropped; single packages and repeated flags are unchanged. * test(cli): cover comma-split trimming/empty-drop and --ignore Address review feedback: add tests for the whitespace trimming and .filter(Boolean) empty-entry dropping in the comma-separated flag expansion, and cover the version command's --ignore flag which shares the same normalizeOptions path. Note the --ignore support (and the trim/empty behavior) in the changeset entry. --------- Co-authored-by: youdie006 <youdie006@users.noreply.github.com> Co-authored-by: bluwy <bjornlu.dev@gmail.com>
1 parent 489360a commit fd7724a

3 files changed

Lines changed: 53 additions & 4 deletions

File tree

Lines changed: 5 additions & 0 deletions

‎packages/cli/src/cli.test.ts‎

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,28 @@ const tests: CommandTest[] = [
8787
patch: ["pkg-c", "pkg-d"],
8888
},
8989
},
90+
{
91+
args: [
92+
"--minor",
93+
"pkg-a, pkg-b",
94+
"--patch",
95+
"pkg-c,pkg-d",
96+
"--patch",
97+
"pkg-e",
98+
],
99+
options: {
100+
minor: ["pkg-a", "pkg-b"],
101+
patch: ["pkg-c", "pkg-d", "pkg-e"],
102+
},
103+
},
104+
{
105+
// Surrounding whitespace is trimmed and empty entries (from repeated
106+
// or trailing commas) are dropped via `.filter(Boolean)`.
107+
args: ["--patch", " pkg-a , , pkg-b , "],
108+
options: {
109+
patch: ["pkg-a", "pkg-b"],
110+
},
111+
},
90112
],
91113
},
92114
{
@@ -103,6 +125,20 @@ const tests: CommandTest[] = [
103125
ignore: ["pkg-a", "pkg-b"],
104126
},
105127
},
128+
{
129+
// The same comma-separated expansion applies to `--ignore`.
130+
args: ["--ignore", "pkg-a,pkg-b"],
131+
options: {
132+
ignore: ["pkg-a", "pkg-b"],
133+
},
134+
},
135+
{
136+
// ...including trimming and dropping empty entries.
137+
args: ["--ignore", " pkg-a , , pkg-b , "],
138+
options: {
139+
ignore: ["pkg-a", "pkg-b"],
140+
},
141+
},
106142
{
107143
args: ["--snapshot"],
108144
options: {

‎packages/cli/src/cli.ts‎

Lines changed: 12 additions & 4 deletions

0 commit comments

Comments
 (0)