Skip to content

Commit

Permalink
fix(options): Explicit --ignore-prepublish
Browse files Browse the repository at this point in the history
  • Loading branch information
evocateur committed Oct 14, 2019
1 parent f2c8ab3 commit fa21723
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 0 deletions.
17 changes: 17 additions & 0 deletions commands/publish/__tests__/publish-lifecycle-scripts.test.js
Expand Up @@ -119,4 +119,21 @@ Map {
// (they are all run by pack-directory and npm-publish)
]);
});

it("respects --ignore-prepublish", async () => {
const cwd = await initFixture("lifecycle");

await lernaPublish(cwd)("--ignore-prepublish");

expect(packDirectory).toHaveBeenCalledWith(
expect.objectContaining({ name: "package-2" }),
path.join(cwd, "packages/package-2"),
expect.objectContaining({
"ignore-prepublish": true,
})
);

// runLifecycle() is _called_ with "prepublish" for root,
// but it does not actually execute, and is tested elsewhere
});
});
4 changes: 4 additions & 0 deletions commands/publish/command.js
Expand Up @@ -46,6 +46,10 @@ exports.builder = yargs => {
choices: ["all", "dependencies"],
defaultDescription: "dependencies",
},
"ignore-prepublish": {
describe: "Disable deprecated 'prepublish' lifecycle script",
type: "boolean",
},
otp: {
describe: "Supply a one-time password for publishing with two-factor authentication.",
type: "string",
Expand Down
1 change: 1 addition & 0 deletions commands/publish/index.js
Expand Up @@ -120,6 +120,7 @@ class PublishCommand extends Command {
npmVersion: this.userAgent,
otp: this.options.otp,
registry: this.options.registry,
"ignore-prepublish": this.options.ignorePrepublish,
});

// cache to hold a one-time-password across publishes
Expand Down
9 changes: 9 additions & 0 deletions integration/lerna-publish-lifecycle.test.js
Expand Up @@ -115,3 +115,12 @@ Successfully published:
- package-2@1.1.0
`);
});

test("lerna publish --ignore-prepublish", async () => {
const { cwd } = await cloneFixture("lifecycle");
const args = ["publish", "--ignore-prepublish", "patch", "--yes"];

const { stdout } = await cliRunner(cwd, env)(...args);
expect(stdout).not.toContain("prepublish-root");
expect(stdout).not.toContain("prepublish-package-2");
});

0 comments on commit fa21723

Please sign in to comment.