Skip to content

Commit 2be75fa

Browse files
GeeWizWowantongolub
authored andcommitted
fix: ensure msr cli flags take precedence over their semrel equivalents
1 parent 888cb37 commit 2be75fa

File tree

3 files changed

+16
-8
lines changed

3 files changed

+16
-8
lines changed

lib/getConfigMultiSemrel.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ export default async function getConfig(cwd, cliOptions) {
6767
ignorePrivate: true,
6868
ignorePackages: [],
6969
tagFormat: "${name}@${version}",
70-
dryRun: false,
70+
dryRun: undefined,
7171
deps: {
7272
bump: "override",
7373
release: "patch",

lib/multiSemanticRelease.js

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -180,8 +180,7 @@ async function releasePackage(pkg, createInlinePlugin, multiContext, flags) {
180180
// This consists of:
181181
// - The global options (e.g. from the top level package.json)
182182
// - The package options (e.g. from the specific package's package.json)
183-
// TODO filter flags
184-
const options = { ...flags, ...pkgOptions, ...inlinePlugin };
183+
const options = { ...pkgOptions, ...inlinePlugin };
185184

186185
// Add the package name into tagFormat.
187186
// Thought about doing a single release for the tag (merging several packages), but it's impossible to prevent Github releasing while allowing NPM to continue.
@@ -194,6 +193,14 @@ async function releasePackage(pkg, createInlinePlugin, multiContext, flags) {
194193
const tagFormatDefault = "${name}@${version}";
195194
options.tagFormat = template(flags.tagFormat || tagFormatDefault)(tagFormatCtx);
196195

196+
// These are the only two options that MSR shares with semrel
197+
// Set them manually for now, defaulting to the msr versions
198+
// This is approach can be reviewed if there's ever more crossover.
199+
// - debug is only supported in semrel as a CLI arg, always default to MSR
200+
options.debug = flags.debug;
201+
// - dryRun should use the msr version if specified, otherwise fallback to semrel
202+
options.dryRun = flags.dryRun === undefined ? options.dryRun : flags.dryRun;
203+
197204
// This options are needed for plugins that do not rely on `pluginOptions` and extract them independently.
198205
options._pkgOptions = pkgOptions;
199206

test/lib/getConfigMultiSemrel.test.js

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ describe("getConfig()", () => {
1414
ignorePrivate: true,
1515
ignorePackages: [],
1616
tagFormat: "${name}@${version}",
17-
dryRun: false,
17+
dryRun: undefined,
1818
deps: {
1919
bump: "override",
2020
release: "patch",
@@ -26,6 +26,7 @@ describe("getConfig()", () => {
2626
test("Only CLI flags and default options", async () => {
2727
const cliFlags = {
2828
debug: true,
29+
dryRun: false,
2930
ignorePackages: ["!packages/d/**"],
3031
deps: {
3132
bump: "inherit",
@@ -61,7 +62,7 @@ describe("getConfig()", () => {
6162
ignorePrivate: true,
6263
ignorePackages: ["!packages/d/**"],
6364
tagFormat: "${name}@${version}",
64-
dryRun: false,
65+
dryRun: undefined,
6566
deps: {
6667
bump: "inherit",
6768
release: "patch",
@@ -89,7 +90,7 @@ describe("getConfig()", () => {
8990
ignorePrivate: true,
9091
ignorePackages: ["!packages/d/**", "!packages/c/**"],
9192
tagFormat: "${name}@${version}",
92-
dryRun: false,
93+
dryRun: undefined,
9394
deps: {
9495
bump: "inherit",
9596
release: "minor",
@@ -110,7 +111,7 @@ describe("getConfig()", () => {
110111
ignorePrivate: true,
111112
ignorePackages: ["!packages/d/**"],
112113
tagFormat: "${name}@${version}",
113-
dryRun: false,
114+
dryRun: undefined,
114115
deps: {
115116
bump: "satisfy",
116117
release: "patch",
@@ -138,7 +139,7 @@ describe("getConfig()", () => {
138139
ignorePrivate: true,
139140
ignorePackages: ["!packages/d/**", "!packages/c/**"],
140141
tagFormat: "${name}@${version}",
141-
dryRun: false,
142+
dryRun: undefined,
142143
deps: {
143144
bump: "satisfy",
144145
release: "minor",

0 commit comments

Comments
 (0)