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
diff options
context:
space:
mode:
authorisaacs <i@izs.me>2020-10-22 19:30:36 +0300
committerisaacs <i@izs.me>2020-10-23 20:16:01 +0300
commit59e8dd6c621f9a5c6e0b65533d8256be87a8e0d3 (patch)
tree9c9e8664b88966027bd7c63af44aec83f8206c9c /test/lib/npm.js
parentcc026daf8c8330256de01375350a1407064562f9 (diff)
Properly set npm_command environment variable.
Fix: #2015 PR-URL: https://github.com/npm/cli/pull/2016 Credit: @isaacs Close: #2016 Reviewed-by: @ruyadorno
Diffstat (limited to 'test/lib/npm.js')
-rw-r--r--test/lib/npm.js9
1 files changed, 9 insertions, 0 deletions
diff --git a/test/lib/npm.js b/test/lib/npm.js
index 296817849..b2be5543f 100644
--- a/test/lib/npm.js
+++ b/test/lib/npm.js
@@ -4,7 +4,16 @@ const fs = require('fs')
// delete this so that we don't have configs from the fact that it
// is being run by 'npm test'
+const event = process.env.npm_lifecycle_event
for (const env of Object.keys(process.env).filter(e => /^npm_/.test(e))) {
+ if (env === 'npm_command') {
+ // should only be running this in the 'test' or 'run-script' command!
+ // if the lifecycle event is 'test', then it'll be 'test', otherwise
+ // it should always be run-script. Of course, it'll be missing if this
+ // test is just run directly, which is also acceptable.
+ const cmd = event === 'test' ? 'test' : 'run-script'
+ t.match(process.env[env], cmd)
+ }
delete process.env[env]
}