@@ -10,18 +10,18 @@ process.argv.splice(2, 0, 'exec')
10
10
const removedSwitches = new Set ( [
11
11
'always-spawn' ,
12
12
'ignore-existing' ,
13
- 'shell-auto-fallback'
13
+ 'shell-auto-fallback' ,
14
14
] )
15
15
16
16
const removedOpts = new Set ( [
17
17
'npm' ,
18
18
'node-arg' ,
19
- 'n'
19
+ 'n' ,
20
20
] )
21
21
22
22
const removed = new Set ( [
23
23
...removedSwitches ,
24
- ...removedOpts
24
+ ...removedOpts ,
25
25
] )
26
26
27
27
const { definitions, shorthands } = require ( '../lib/utils/config/index.js' )
@@ -40,7 +40,7 @@ const switches = new Set([
40
40
'version' ,
41
41
'v' ,
42
42
'help' ,
43
- 'h'
43
+ 'h' ,
44
44
] )
45
45
46
46
// things that do take a value
@@ -55,7 +55,7 @@ const opts = new Set([
55
55
'shell' ,
56
56
'npm' ,
57
57
'node-arg' ,
58
- 'n'
58
+ 'n' ,
59
59
] )
60
60
61
61
// break out of loop when we find a positional argument or --
65
65
let sawRemovedFlags = false
66
66
for ( i = 3 ; i < process . argv . length ; i ++ ) {
67
67
const arg = process . argv [ i ]
68
- if ( arg === '--' ) {
68
+ if ( arg === '--' )
69
69
break
70
- } else if ( / ^ - / . test ( arg ) ) {
70
+ else if ( / ^ - / . test ( arg ) ) {
71
71
const [ key , ...v ] = arg . replace ( / ^ - + / , '' ) . split ( '=' )
72
72
73
73
switch ( key ) {
@@ -87,9 +87,8 @@ for (i = 3; i < process.argv.length; i++) {
87
87
// resolve shorthands and run again
88
88
if ( shorthands [ key ] && ! removed . has ( key ) ) {
89
89
const a = [ ...shorthands [ key ] ]
90
- if ( v . length ) {
90
+ if ( v . length )
91
91
a . push ( v . join ( '=' ) )
92
- }
93
92
process . argv . splice ( i , 1 , ...a )
94
93
i --
95
94
continue
@@ -110,9 +109,8 @@ for (i = 3; i < process.argv.length; i++) {
110
109
if ( removed . has ( key ) ) {
111
110
// also remove the value for the cut key.
112
111
process . argv . splice ( i + 1 , 1 )
113
- } else {
112
+ } else
114
113
i ++
115
- }
116
114
}
117
115
} else {
118
116
// found a positional arg, put -- in front of it, and we're done
@@ -121,8 +119,7 @@ for (i = 3; i < process.argv.length; i++) {
121
119
}
122
120
}
123
121
124
- if ( sawRemovedFlags ) {
122
+ if ( sawRemovedFlags )
125
123
console . error ( 'See `npm help exec` for more information' )
126
- }
127
124
128
125
cli ( process )
0 commit comments