Commit a8dd25c 1 parent 627cf80 commit a8dd25c Copy full SHA for a8dd25c
File tree 2 files changed +13
-2
lines changed
2 files changed +13
-2
lines changed Original file line number Diff line number Diff line change @@ -93,7 +93,10 @@ const npm = module.exports = new class extends EventEmitter {
93
93
}
94
94
95
95
process . emit ( 'time' , `command:${ cmd } ` )
96
- this . command = cmd
96
+ if ( ! this . command ) {
97
+ process . env . npm_command = cmd
98
+ this . command = cmd
99
+ }
97
100
98
101
// Options are prefixed by a hyphen-minus (-, \u2d).
99
102
// Other dash-type chars look similar but are invalid.
@@ -142,7 +145,6 @@ const npm = module.exports = new class extends EventEmitter {
142
145
}
143
146
if ( ! er && ! this [ _flatOptions ] ) {
144
147
this [ _flatOptions ] = require ( './utils/flat-options.js' ) ( this )
145
- process . env . npm_command = this . command
146
148
}
147
149
process . emit ( 'timeEnd' , 'npm:load' )
148
150
this . emit ( 'load' , er )
Original file line number Diff line number Diff line change @@ -5,6 +5,15 @@ const fs = require('fs')
5
5
// delete this so that we don't have configs from the fact that it
6
6
// is being run by 'npm test'
7
7
for ( const env of Object . keys ( process . env ) . filter ( e => / ^ n p m _ / . test ( e ) ) ) {
8
+ if ( env === 'npm_command' ) {
9
+ // should only be running this in the 'test' or 'run-script' command!
10
+ // if the lifecycle event is 'snap', then it'll be run-script, otherwise
11
+ // it should always be test. Of course, it'll be missing if this test
12
+ // is just run directly, which is also acceptable.
13
+ const cmd = process . env . npm_lifecycle_event === 'snap' ? 'run-script'
14
+ : 'test'
15
+ t . match ( process . env [ env ] , cmd )
16
+ }
8
17
delete process . env [ env ]
9
18
}
10
19
You can’t perform that action at this time.
0 commit comments