Skip to content

Commit

Permalink
fix: ensure msr cli flags take precedence over their semrel equivalents
Browse files Browse the repository at this point in the history
  • Loading branch information
GeeWizWow authored and antongolub committed Jun 14, 2022
1 parent 888cb37 commit 2be75fa
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 8 deletions.
2 changes: 1 addition & 1 deletion lib/getConfigMultiSemrel.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ export default async function getConfig(cwd, cliOptions) {
ignorePrivate: true,
ignorePackages: [],
tagFormat: "${name}@${version}",
dryRun: false,
dryRun: undefined,
deps: {
bump: "override",
release: "patch",
Expand Down
11 changes: 9 additions & 2 deletions lib/multiSemanticRelease.js
Original file line number Diff line number Diff line change
Expand Up @@ -180,8 +180,7 @@ async function releasePackage(pkg, createInlinePlugin, multiContext, flags) {
// This consists of:
// - The global options (e.g. from the top level package.json)
// - The package options (e.g. from the specific package's package.json)
// TODO filter flags
const options = { ...flags, ...pkgOptions, ...inlinePlugin };
const options = { ...pkgOptions, ...inlinePlugin };

// Add the package name into tagFormat.
// 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.
Expand All @@ -194,6 +193,14 @@ async function releasePackage(pkg, createInlinePlugin, multiContext, flags) {
const tagFormatDefault = "${name}@${version}";
options.tagFormat = template(flags.tagFormat || tagFormatDefault)(tagFormatCtx);

// These are the only two options that MSR shares with semrel
// Set them manually for now, defaulting to the msr versions
// This is approach can be reviewed if there's ever more crossover.
// - debug is only supported in semrel as a CLI arg, always default to MSR
options.debug = flags.debug;
// - dryRun should use the msr version if specified, otherwise fallback to semrel
options.dryRun = flags.dryRun === undefined ? options.dryRun : flags.dryRun;

// This options are needed for plugins that do not rely on `pluginOptions` and extract them independently.
options._pkgOptions = pkgOptions;

Expand Down
11 changes: 6 additions & 5 deletions test/lib/getConfigMultiSemrel.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ describe("getConfig()", () => {
ignorePrivate: true,
ignorePackages: [],
tagFormat: "${name}@${version}",
dryRun: false,
dryRun: undefined,
deps: {
bump: "override",
release: "patch",
Expand All @@ -26,6 +26,7 @@ describe("getConfig()", () => {
test("Only CLI flags and default options", async () => {
const cliFlags = {
debug: true,
dryRun: false,
ignorePackages: ["!packages/d/**"],
deps: {
bump: "inherit",
Expand Down Expand Up @@ -61,7 +62,7 @@ describe("getConfig()", () => {
ignorePrivate: true,
ignorePackages: ["!packages/d/**"],
tagFormat: "${name}@${version}",
dryRun: false,
dryRun: undefined,
deps: {
bump: "inherit",
release: "patch",
Expand Down Expand Up @@ -89,7 +90,7 @@ describe("getConfig()", () => {
ignorePrivate: true,
ignorePackages: ["!packages/d/**", "!packages/c/**"],
tagFormat: "${name}@${version}",
dryRun: false,
dryRun: undefined,
deps: {
bump: "inherit",
release: "minor",
Expand All @@ -110,7 +111,7 @@ describe("getConfig()", () => {
ignorePrivate: true,
ignorePackages: ["!packages/d/**"],
tagFormat: "${name}@${version}",
dryRun: false,
dryRun: undefined,
deps: {
bump: "satisfy",
release: "patch",
Expand Down Expand Up @@ -138,7 +139,7 @@ describe("getConfig()", () => {
ignorePrivate: true,
ignorePackages: ["!packages/d/**", "!packages/c/**"],
tagFormat: "${name}@${version}",
dryRun: false,
dryRun: undefined,
deps: {
bump: "satisfy",
release: "minor",
Expand Down

0 comments on commit 2be75fa

Please sign in to comment.