Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(npm): repect allowScripts & ignoreScripts #9684

Merged
merged 4 commits into from Apr 22, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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