Skip to content

Commit

Permalink
fix(version): Workaround yargs bug with spurious -- arguments
Browse files Browse the repository at this point in the history
Fixes #2315
  • Loading branch information
evocateur committed Oct 22, 2019
1 parent 384cd15 commit 46be9dc
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
10 changes: 10 additions & 0 deletions commands/version/__tests__/version-command.test.js
Expand Up @@ -734,4 +734,14 @@ describe("VersionCommand", () => {
expect(changedFiles).toContain("packages/package-1/package-lock.json");
});
});

describe("with spurious -- arguments", () => {
it("ignores the extra arguments with cheesy parseConfiguration()", async () => {
const cwd = await initFixture("lifecycle");
await lernaVersion(cwd)("--yes", "--", "--loglevel", "ignored", "--blah");

const logMessages = loggingOutput("warn");
expect(logMessages).toContain("Arguments after -- are no longer passed to subprocess executions.");
});
});
});
10 changes: 10 additions & 0 deletions commands/version/command.js
Expand Up @@ -156,6 +156,11 @@ exports.builder = (yargs, composed) => {

yargs.options(opts);

// workaround yargs bug that re-interprets unknown arguments in argv._
yargs.parserConfiguration({
"populate--": true,
});

if (!composed) {
// hide options from composed command's help output
yargs.group(Object.keys(opts), "Command Options:");
Expand Down Expand Up @@ -231,6 +236,11 @@ exports.builder = (yargs, composed) => {
}
/* eslint-enable no-param-reassign */

if (argv["--"]) {
log.warn("EDOUBLEDASH", "Arguments after -- are no longer passed to subprocess executions.");
log.warn("EDOUBLEDASH", "This will cause an error in a future major version.");
}

return argv;
});
};
Expand Down

0 comments on commit 46be9dc

Please sign in to comment.