Skip to content

Commit

Permalink
fix(npm): repect allowScripts & ignoreScripts (#9684)
Browse files Browse the repository at this point in the history
Co-authored-by: Rhys Arkins <rhys@arkins.net>
  • Loading branch information
viceice and rarkins committed Apr 22, 2021
1 parent cf46043 commit 8c0f7c1
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 5 deletions.
6 changes: 3 additions & 3 deletions lib/manager/npm/post-update/__snapshots__/npm.spec.ts.snap
Expand Up @@ -7,7 +7,7 @@ exports[`generateLockFile finds npm globally 1`] = `Array []`;
exports[`generateLockFile generates lock files 1`] = `
Array [
Object {
"cmd": "npm install --ignore-scripts --no-audit",
"cmd": "npm install --no-audit --ignore-scripts",
"options": Object {
"cwd": "some-dir",
"encoding": "utf-8",
Expand Down Expand Up @@ -50,7 +50,7 @@ exports[`generateLockFile performs full install 1`] = `Array []`;
exports[`generateLockFile performs lock file maintenance 1`] = `
Array [
Object {
"cmd": "npm install --package-lock-only --ignore-scripts --no-audit",
"cmd": "npm install --package-lock-only --no-audit --ignore-scripts",
"options": Object {
"cwd": "some-dir",
"encoding": "utf-8",
Expand All @@ -73,7 +73,7 @@ Array [
exports[`generateLockFile performs lock file updates 1`] = `
Array [
Object {
"cmd": "npm install --package-lock-only --ignore-scripts --no-audit some-dep@1.0.1",
"cmd": "npm install --package-lock-only --no-audit --ignore-scripts some-dep@1.0.1",
"options": Object {
"cwd": "some-dir",
"encoding": "utf-8",
Expand Down
9 changes: 7 additions & 2 deletions lib/manager/npm/post-update/npm.ts
Expand Up @@ -51,11 +51,16 @@ export async function generateLockFile(
let cmdOptions = '';
if (postUpdateOptions?.includes('npmDedupe') || skipInstalls === false) {
logger.debug('Performing node_modules install');
cmdOptions += '--ignore-scripts --no-audit';
cmdOptions += '--no-audit';
} else {
logger.debug('Updating lock file only');
cmdOptions += '--package-lock-only --ignore-scripts --no-audit';
cmdOptions += '--package-lock-only --no-audit';
}

if (!getAdminConfig().allowScripts || config.ignoreScripts) {
cmdOptions += ' --ignore-scripts';
}

const tagConstraint = await getNodeConstraint(config);
const execOptions: ExecOptions = {
cwd,
Expand Down
1 change: 1 addition & 0 deletions lib/manager/types.ts
Expand Up @@ -277,6 +277,7 @@ export interface PostUpdateConfig extends ManagerConfig, Record<string, any> {
updatedPackageFiles?: File[];
postUpdateOptions?: string[];
skipInstalls?: boolean;
ignoreScripts?: boolean;

platform?: string;
upgrades?: Upgrade[];
Expand Down

0 comments on commit 8c0f7c1

Please sign in to comment.