@@ -93,14 +93,7 @@ class Npm {
93
93
}
94
94
95
95
async load ( ) {
96
- return time . start ( 'npm:load' , async ( ) => {
97
- const { exec } = await this . #load( )
98
- return {
99
- exec,
100
- command : this . argv . shift ( ) ,
101
- args : this . argv ,
102
- }
103
- } )
96
+ return time . start ( 'npm:load' , ( ) => this . #load( ) )
104
97
}
105
98
106
99
get loaded ( ) {
@@ -165,7 +158,26 @@ class Npm {
165
158
166
159
await time . start ( 'npm:load:configload' , ( ) => this . config . load ( ) )
167
160
161
+ // npm --versions
162
+ if ( this . config . get ( 'versions' , 'cli' ) ) {
163
+ this . argv = [ 'version' ]
164
+ this . config . set ( 'usage' , false , 'cli' )
165
+ } else {
166
+ this . argv = [ ...this . config . parsedArgv . remain ]
167
+ }
168
+
169
+ // Remove first argv since that is our command as typed
170
+ // Note that this might not be the actual name of the command
171
+ // due to aliases, etc. But we use the raw form of it later
172
+ // in user output so it must be preserved as is.
173
+ const commandArg = this . argv . shift ( )
174
+
175
+ // This is the actual name of the command that will be run or
176
+ // undefined if deref could not find a match
177
+ const command = deref ( commandArg )
178
+
168
179
await this . #display. load ( {
180
+ command,
169
181
loglevel : this . config . get ( 'loglevel' ) ,
170
182
stdoutColor : this . color ,
171
183
stderrColor : this . logColor ,
@@ -202,9 +214,10 @@ class Npm {
202
214
203
215
// note: this MUST be shorter than the actual argv length, because it
204
216
// uses the same memory, so node will truncate it if it's too long.
217
+ // We time this because setting process.title is slow sometimes but we
218
+ // have to do it for security reasons. But still helpful to know how slow it is.
205
219
time . start ( 'npm:load:setTitle' , ( ) => {
206
220
const { parsedArgv : { cooked, remain } } = this . config
207
- this . argv = remain
208
221
// Secrets are mostly in configs, so title is set using only the positional args
209
222
// to keep those from being leaked. We still do a best effort replaceInfo.
210
223
this . #title = [ 'npm' ] . concat ( replaceInfo ( remain ) ) . join ( ' ' ) . trim ( )
@@ -244,13 +257,7 @@ class Npm {
244
257
log . warn ( 'using --force' , 'Recommended protections disabled.' )
245
258
}
246
259
247
- // npm --versions
248
- if ( this . config . get ( 'versions' , 'cli' ) ) {
249
- this . argv = [ 'version' ]
250
- this . config . set ( 'usage' , false , 'cli' )
251
- }
252
-
253
- return { exec : true }
260
+ return { exec : true , command : commandArg , args : this . argv }
254
261
}
255
262
256
263
get isShellout ( ) {
0 commit comments