From 840c338aa6aba7dc39d9d3afba075701e3979362 Mon Sep 17 00:00:00 2001 From: Ruy Adorno Date: Tue, 5 Apr 2022 09:39:00 -0400 Subject: [PATCH] fix(run-script): don't cascade if-present config (#4678) Do not pass the `if-present` env config value to spawned processes. Fixes: https://github.com/npm/cli/issues/3352 Close: https://github.com/npm/cli/pull/3589 --- docs/content/commands/npm-run-script.md | 2 ++ docs/content/using-npm/config.md | 2 ++ lib/utils/config/definitions.js | 1 + tap-snapshots/test/lib/utils/config/definitions.js.test.cjs | 2 ++ tap-snapshots/test/lib/utils/config/describe-all.js.test.cjs | 2 ++ 5 files changed, 9 insertions(+) diff --git a/docs/content/commands/npm-run-script.md b/docs/content/commands/npm-run-script.md index aab8d769dc9e2..73c4b1c7a748a 100644 --- a/docs/content/commands/npm-run-script.md +++ b/docs/content/commands/npm-run-script.md @@ -220,6 +220,8 @@ it's present and fail if the script fails. This is useful, for example, when running scripts that may only apply for some builds in an otherwise generic CI setup. +This value is not exported to the environment for child processes. + diff --git a/docs/content/using-npm/config.md b/docs/content/using-npm/config.md index 858fe4d638bed..71dab98a3831e 100644 --- a/docs/content/using-npm/config.md +++ b/docs/content/using-npm/config.md @@ -762,6 +762,8 @@ it's present and fail if the script fails. This is useful, for example, when running scripts that may only apply for some builds in an otherwise generic CI setup. +This value is not exported to the environment for child processes. + diff --git a/lib/utils/config/definitions.js b/lib/utils/config/definitions.js index 316e737091eb4..7ff0eeb1283c5 100644 --- a/lib/utils/config/definitions.js +++ b/lib/utils/config/definitions.js @@ -880,6 +880,7 @@ define('https-proxy', { define('if-present', { default: false, type: Boolean, + envExport: false, description: ` If true, npm will not exit with an error code when \`run-script\` is invoked for a script that isn't defined in the \`scripts\` section of diff --git a/tap-snapshots/test/lib/utils/config/definitions.js.test.cjs b/tap-snapshots/test/lib/utils/config/definitions.js.test.cjs index b18b8e7a829e6..91f0d782878a3 100644 --- a/tap-snapshots/test/lib/utils/config/definitions.js.test.cjs +++ b/tap-snapshots/test/lib/utils/config/definitions.js.test.cjs @@ -795,6 +795,8 @@ This option can be used when it's desirable to optionally run a script when it's present and fail if the script fails. This is useful, for example, when running scripts that may only apply for some builds in an otherwise generic CI setup. + +This value is not exported to the environment for child processes. ` exports[`test/lib/utils/config/definitions.js TAP > config description for ignore-scripts 1`] = ` diff --git a/tap-snapshots/test/lib/utils/config/describe-all.js.test.cjs b/tap-snapshots/test/lib/utils/config/describe-all.js.test.cjs index 564ade46e731d..7b13c34daf682 100644 --- a/tap-snapshots/test/lib/utils/config/describe-all.js.test.cjs +++ b/tap-snapshots/test/lib/utils/config/describe-all.js.test.cjs @@ -636,6 +636,8 @@ it's present and fail if the script fails. This is useful, for example, when running scripts that may only apply for some builds in an otherwise generic CI setup. +This value is not exported to the environment for child processes. +