From 47ed2dfd865566643bc1d39e8a4f98d2e1add99a Mon Sep 17 00:00:00 2001 From: isaacs Date: Tue, 5 Jan 2021 16:24:00 -0800 Subject: [PATCH] add foreground-scripts option PR-URL: https://github.com/npm/cli/pull/2456 Credit: @isaacs Close: #2456 Reviewed-by: @ruyadorno --- docs/content/using-npm/config.md | 12 ++++++++++++ lib/utils/config.js | 2 ++ lib/utils/flat-options.js | 1 + tap-snapshots/test-lib-utils-config.js-TAP.test.js | 4 ++++ .../test-lib-utils-flat-options.js-TAP.test.js | 1 + 5 files changed, 20 insertions(+) diff --git a/docs/content/using-npm/config.md b/docs/content/using-npm/config.md index 2d9a4f8698a98..3a2517d34ef9a 100644 --- a/docs/content/using-npm/config.md +++ b/docs/content/using-npm/config.md @@ -419,6 +419,18 @@ mistakes, unnecessary performance degradation, and malicious input. If you don't have a clear idea of what you want to do, it is strongly recommended that you do not use this option! +#### foreground-scripts + +* Default: false +* Type: Boolean + +Run all build scripts (ie, `preinstall`, `install`, and `postinstall`) +scripts for installed packages in the foreground process, sharing standard +input, output, and error with the main npm process. + +Note that this will generally make installs run slower, and be much +noisier, but can be useful for debugging. + #### format-package-lock * Default: true diff --git a/lib/utils/config.js b/lib/utils/config.js index 426f0a5291406..511215769893e 100644 --- a/lib/utils/config.js +++ b/lib/utils/config.js @@ -83,6 +83,7 @@ const defaults = { 'fetch-retry-mintimeout': 10000, 'fetch-timeout': 5 * 60 * 1000, force: false, + 'foreground-script': false, 'format-package-lock': true, fund: true, git: 'git', @@ -224,6 +225,7 @@ const types = { 'fetch-retry-mintimeout': Number, 'fetch-timeout': Number, force: Boolean, + 'foreground-script': Boolean, 'format-package-lock': Boolean, fund: Boolean, git: String, diff --git a/lib/utils/flat-options.js b/lib/utils/flat-options.js index 828481930369c..a161ff2e6a70f 100644 --- a/lib/utils/flat-options.js +++ b/lib/utils/flat-options.js @@ -133,6 +133,7 @@ const flatten = obj => ({ packageLockOnly: obj['package-lock-only'], globalStyle: obj['global-style'], legacyBundling: obj['legacy-bundling'], + foregroundScripts: !!obj['foreground-scripts'], scriptShell: obj['script-shell'] || undefined, shell: obj.shell, omit: buildOmitList(obj), diff --git a/tap-snapshots/test-lib-utils-config.js-TAP.test.js b/tap-snapshots/test-lib-utils-config.js-TAP.test.js index 019247cd5244f..1f525e71cab97 100644 --- a/tap-snapshots/test-lib-utils-config.js-TAP.test.js +++ b/tap-snapshots/test-lib-utils-config.js-TAP.test.js @@ -46,6 +46,7 @@ Object { "fetch-retry-mintimeout": 10000, "fetch-timeout": 300000, "force": false, + "foreground-script": false, "format-package-lock": true, "fund": true, "git": "git", @@ -354,6 +355,7 @@ Object { "fetch-retry-mintimeout": "{Number TYPE}", "fetch-timeout": "{Number TYPE}", "force": "{Boolean TYPE}", + "foreground-script": "{Boolean TYPE}", "format-package-lock": "{Boolean TYPE}", "fund": "{Boolean TYPE}", "git": "{String TYPE}", @@ -573,6 +575,7 @@ Object { "fetch-retry-mintimeout": 10000, "fetch-timeout": 300000, "force": false, + "foreground-script": false, "format-package-lock": true, "fund": true, "git": "git", @@ -881,6 +884,7 @@ Object { "fetch-retry-mintimeout": "{Number TYPE}", "fetch-timeout": "{Number TYPE}", "force": "{Boolean TYPE}", + "foreground-script": "{Boolean TYPE}", "format-package-lock": "{Boolean TYPE}", "fund": "{Boolean TYPE}", "git": "{String TYPE}", diff --git a/tap-snapshots/test-lib-utils-flat-options.js-TAP.test.js b/tap-snapshots/test-lib-utils-flat-options.js-TAP.test.js index 36f76712410b6..93606fcd8a060 100644 --- a/tap-snapshots/test-lib-utils-flat-options.js-TAP.test.js +++ b/tap-snapshots/test-lib-utils-flat-options.js-TAP.test.js @@ -36,6 +36,7 @@ Object { "engineStrict": "engine-strict", "fmode": 438, "force": "force", + "foregroundScripts": false, "formatPackageLock": "format-package-lock", "fund": "fund", "git": "git",