Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/npm/cli.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/lib/ci.js
diff options
context:
space:
mode:
authorisaacs <i@izs.me>2020-12-10 01:17:36 +0300
committerisaacs <i@izs.me>2020-12-11 22:30:50 +0300
commitd825e901eceea4cf8d860e35238dc30008eb4da4 (patch)
treefe8931e751d7b7d082046270802dc389a7daf30f /lib/ci.js
parent7ff6efbb866591b2330b967215cef8146dff3ebf (diff)
ci: run install scripts for root projectisaacs/ci-scripts
`npm ci` should run all the same preinstall/install/postinstall/prepare scripts for the root project just like `npm install`. Fixes: #1905 PR-URL: https://github.com/npm/cli/pull/2316 Credit: @isaacs Close: #2316 Reviewed-by: @ruyadorno
Diffstat (limited to 'lib/ci.js')
-rw-r--r--lib/ci.js23
1 files changed, 23 insertions, 0 deletions
diff --git a/lib/ci.js b/lib/ci.js
index 1255fbc26..2917899c8 100644
--- a/lib/ci.js
+++ b/lib/ci.js
@@ -2,6 +2,7 @@ const util = require('util')
const Arborist = require('@npmcli/arborist')
const rimraf = util.promisify(require('rimraf'))
const reifyFinish = require('./utils/reify-finish.js')
+const runScript = require('@npmcli/run-script')
const log = require('npmlog')
const npm = require('./npm.js')
@@ -20,6 +21,7 @@ const ci = async () => {
}
const where = npm.prefix
+ const { scriptShell } = npm.flatOptions
const arb = new Arborist({ ...npm.flatOptions, path: where })
await Promise.all([
@@ -35,6 +37,27 @@ const ci = async () => {
])
// npm ci should never modify the lockfile or package.json
await arb.reify({ ...npm.flatOptions, save: false })
+
+ // run the same set of scripts that `npm install` runs.
+ const scripts = [
+ 'preinstall',
+ 'install',
+ 'postinstall',
+ 'prepublish', // XXX should we remove this finally??
+ 'preprepare',
+ 'prepare',
+ 'postprepare',
+ ]
+ for (const event of scripts) {
+ await runScript({
+ path: where,
+ args: [],
+ scriptShell,
+ stdio: 'inherit',
+ stdioString: true,
+ event,
+ })
+ }
await reifyFinish(arb)
}