Skip to content

Commit

Permalink
fix(bootstrap): Don't pass --ignore-scripts to npm install
Browse files Browse the repository at this point in the history
Fixes #1855
  • Loading branch information
evocateur committed Jan 8, 2019
1 parent 1c1ac15 commit e602838
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 8 deletions.
Expand Up @@ -3,5 +3,8 @@
"version": "1.0.0",
"scripts": {
"prepare": "touch did-prepare"
},
"dependencies": {
"tiny-tarball": "^1.0.0"
}
}
21 changes: 15 additions & 6 deletions commands/bootstrap/__tests__/bootstrap-command.test.js
Expand Up @@ -112,6 +112,15 @@ describe("BootstrapCommand", () => {
await lernaBootstrap(testDir)("--ignore-scripts");

expect(runLifecycle).not.toHaveBeenCalled();
expect(npmInstall.dependencies).toHaveBeenCalledWith(
expect.objectContaining({
name: "package-prepare",
}),
["tiny-tarball@^1.0.0"],
expect.objectContaining({
npmClientArgs: ["--ignore-scripts"],
})
);
});

it("should not recurse from hoisted root lifecycle", async () => {
Expand Down Expand Up @@ -158,7 +167,7 @@ describe("BootstrapCommand", () => {
{
registry: undefined,
npmClient: "npm",
npmClientArgs: ["--ignore-scripts"],
npmClientArgs: [],
mutex: undefined,
// npmGlobalStyle is not included at all
}
Expand Down Expand Up @@ -225,7 +234,7 @@ describe("BootstrapCommand", () => {
subCommand: "ci",
registry: undefined,
npmClient: "npm",
npmClientArgs: ["--ignore-scripts"],
npmClientArgs: [],
npmGlobalStyle: false,
mutex: undefined,
});
Expand All @@ -241,7 +250,7 @@ describe("BootstrapCommand", () => {
expect(npmInstall.dependencies.mock.calls[0][2]).toEqual({
registry: undefined,
npmClient: "npm",
npmClientArgs: ["--ignore-scripts"],
npmClientArgs: [],
npmGlobalStyle: false,
mutex: undefined,
});
Expand All @@ -263,7 +272,7 @@ describe("BootstrapCommand", () => {
expect(npmInstall.dependencies.mock.calls[0][2]).toEqual({
registry: undefined,
npmClient: "npm",
npmClientArgs: ["--ignore-scripts"],
npmClientArgs: [],
npmGlobalStyle: false,
mutex: undefined,
});
Expand Down Expand Up @@ -493,7 +502,7 @@ describe("BootstrapCommand", () => {
await lernaBootstrap(testDir)("--", "--no-optional", "--production");

expect(npmInstall.dependencies.mock.calls[0][2]).toMatchObject({
npmClientArgs: ["--ignore-scripts", "--no-optional", "--production"],
npmClientArgs: ["--no-optional", "--production"],
});
});
});
Expand All @@ -505,7 +514,7 @@ describe("BootstrapCommand", () => {
await lernaBootstrap(testDir)("--", "--no-optional");

expect(npmInstall.dependencies.mock.calls[0][2]).toMatchObject({
npmClientArgs: ["--ignore-scripts", "--production", "--no-optional"],
npmClientArgs: ["--production", "--no-optional"],
});
});
});
Expand Down
6 changes: 4 additions & 2 deletions commands/bootstrap/index.js
Expand Up @@ -92,8 +92,10 @@ class BootstrapCommand extends Command {
this.npmConfig.npmClientArgs = [...npmClientArgs, ...doubleDashArgs];
}

// lifecycles are always run independently of install subprocess
this.npmConfig.npmClientArgs.unshift("--ignore-scripts");
// do not run any lifecycle scripts (if configured)
if (this.options.ignoreScripts) {
this.npmConfig.npmClientArgs.unshift("--ignore-scripts");
}

// don't execute recursively if run from a poorly-named script
this.runRootLifecycle = /^(pre|post)?install$/.test(process.env.npm_lifecycle_event)
Expand Down

0 comments on commit e602838

Please sign in to comment.