@@ -93,14 +93,7 @@ class Npm {
9393  } 
9494
9595  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( ) ) 
10497  } 
10598
10699  get  loaded  ( )  { 
@@ -165,7 +158,26 @@ class Npm {
165158
166159    await  time . start ( 'npm:load:configload' ,  ( )  =>  this . config . load ( ) ) 
167160
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+ 
168179    await  this . #display. load ( { 
180+       command, 
169181      loglevel : this . config . get ( 'loglevel' ) , 
170182      stdoutColor : this . color , 
171183      stderrColor : this . logColor , 
@@ -202,9 +214,10 @@ class Npm {
202214
203215    // note: this MUST be shorter than the actual argv length, because it 
204216    // 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. 
205219    time . start ( 'npm:load:setTitle' ,  ( )  =>  { 
206220      const  {  parsedArgv : {  cooked,  remain }  }  =  this . config 
207-       this . argv  =  remain 
208221      // Secrets are mostly in configs, so title is set using only the positional args 
209222      // to keep those from being leaked.  We still do a best effort replaceInfo. 
210223      this . #title =  [ 'npm' ] . concat ( replaceInfo ( remain ) ) . join ( ' ' ) . trim ( ) 
@@ -244,13 +257,7 @@ class Npm {
244257      log . warn ( 'using --force' ,  'Recommended protections disabled.' ) 
245258    } 
246259
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  } 
254261  } 
255262
256263  get  isShellout  ( )  { 
0 commit comments