@@ -111,24 +111,23 @@ async function run(
111
111
parentName,
112
112
} )
113
113
114
- const { autopilot, json, markdown } = cli . flags
115
- let { autoMerge, rangeStyle, test } = cli . flags
114
+ const { autopilot, json, markdown } = cli . flags as {
115
+ autopilot : boolean
116
+ json : boolean
117
+ markdown : boolean
118
+ }
116
119
const outputKind = getOutputKind ( json , markdown )
117
- let [ cwd = '.' ] = cli . input
118
- // Note: path.resolve vs .join:
119
- // If given path is absolute then cwd should not affect it.
120
- cwd = path . resolve ( process . cwd ( ) , cwd )
121
120
122
- if ( autopilot ) {
123
- autoMerge = true
124
- test = true
121
+ let rangeStyle = cli . flags [ 'rangeStyle' ] as RangeStyle
122
+ if ( ! rangeStyle ) {
123
+ rangeStyle = 'preserve'
125
124
}
126
125
127
126
const wasValidInput = checkCommandInput ( outputKind , {
128
- test : RangeStyles . includes ( cli . flags [ ' rangeStyle' ] as string ) ,
127
+ test : RangeStyles . includes ( rangeStyle ) ,
129
128
message : `Expecting range style of ${ joinOr ( RangeStyles ) } ` ,
130
129
pass : 'ok' ,
131
- fail : 'missing ' ,
130
+ fail : 'invalid ' ,
132
131
} )
133
132
if ( ! wasValidInput ) {
134
133
return
@@ -139,30 +138,37 @@ async function run(
139
138
return
140
139
}
141
140
142
- let purls : string [ ] = Array . isArray ( cli . flags [ 'purl' ] )
143
- ? cli . flags [ 'purl' ]
144
- : [ ]
145
- purls = purls . flatMap ( p => p . split ( / , * / ) )
141
+ let [ cwd = '.' ] = cli . input
142
+ // Note: path.resolve vs .join:
143
+ // If given path is absolute then cwd should not affect it.
144
+ cwd = path . resolve ( process . cwd ( ) , cwd )
146
145
147
- if (
148
- ! [ 'caret' , 'gt' , 'gte' , 'lt' , 'lte' , 'pin' , 'preserve' , 'tilde' ] . includes (
149
- rangeStyle as string ,
150
- )
151
- ) {
152
- rangeStyle = 'preserve'
146
+ let autoMerge = Boolean ( cli . flags [ 'autoMerge' ] )
147
+ let test = Boolean ( cli . flags [ 'test' ] )
148
+ if ( autopilot ) {
149
+ autoMerge = true
150
+ test = true
153
151
}
154
152
153
+ const limit =
154
+ ( cli . flags [ 'limit' ]
155
+ ? parseInt ( String ( cli . flags [ 'limit' ] || '' ) , 10 )
156
+ : Infinity ) || Infinity
157
+
158
+ const purls : string [ ] = Array . isArray ( cli . flags [ 'purl' ] )
159
+ ? cli . flags [ 'purl' ] . flatMap ( p => p . split ( / , * / ) )
160
+ : [ ]
161
+
162
+ const testScript = String ( cli . flags [ 'testScript' ] || 'test' )
163
+
155
164
await handleFix ( {
156
- autoMerge : Boolean ( autoMerge ) ,
165
+ autoMerge,
157
166
cwd,
158
- limit :
159
- ( cli . flags [ 'limit' ]
160
- ? parseInt ( String ( cli . flags [ 'limit' ] || '' ) , 10 )
161
- : Infinity ) || Infinity ,
167
+ limit,
162
168
outputKind,
163
169
purls,
164
- rangeStyle : rangeStyle as RangeStyle ,
165
- test : Boolean ( test ) ,
166
- testScript : String ( cli . flags [ 'testScript' ] || 'test' ) ,
170
+ rangeStyle,
171
+ test,
172
+ testScript,
167
173
} )
168
174
}
0 commit comments