@@ -16,6 +16,7 @@ import {
16
16
} from '@arethetypeswrong/core'
17
17
import React from 'react'
18
18
import { render , Text , Box , Static } from 'ink'
19
+ import yargs from 'yargs/yargs'
19
20
20
21
const allResolutionKinds : ResolutionKind [ ] = [
21
22
'node10' ,
@@ -232,7 +233,18 @@ function ChecksTable(props: { checks?: Checks }) {
232
233
)
233
234
}
234
235
235
- ; ( async function main ( ) {
236
+ const { argv } = yargs ( process . argv ) . option ( 'nonErrorProblems' , {
237
+ alias : 'n' ,
238
+ type : 'array' ,
239
+ description : 'Do not treat these problems as errors for CLI exit codes' ,
240
+ choices : Object . keys ( problemShortDescriptions ) as ProblemKind [ ] ,
241
+ } )
242
+
243
+ interface CLIOptions {
244
+ nonErrorProblems ?: ProblemKind [ ]
245
+ }
246
+
247
+ ; ( async function main ( { nonErrorProblems = [ ] } : CLIOptions ) {
236
248
const analysis = await checkTgz ( rtkPackageTgzBytes )
237
249
238
250
const checks : Checks = {
@@ -263,6 +275,32 @@ function ChecksTable(props: { checks?: Checks }) {
263
275
</ Static >
264
276
)
265
277
266
- const exitCode = checks . problems ?. length ?? 0
278
+ const { problems = [ ] } = checks
279
+
280
+ console . log ( '\n\nProblem results:' )
281
+
282
+ if ( nonErrorProblems . length ) {
283
+ console . log (
284
+ 'Treating these problem categories as non-errors: ' ,
285
+ nonErrorProblems
286
+ )
287
+ }
288
+
289
+ const filteredProblems = problems . filter (
290
+ ( p ) => ! nonErrorProblems . includes ( p . kind )
291
+ )
292
+
293
+ if ( filteredProblems . length ) {
294
+ console . error (
295
+ 'Remaining problems: ' ,
296
+ filteredProblems . map ( ( p ) => p . kind )
297
+ )
298
+ } else {
299
+ console . log ( 'No errors found!' )
300
+ }
301
+
302
+ const exitCode = filteredProblems . length
267
303
process . exit ( exitCode )
268
- } ) ( )
304
+ } ) ( {
305
+ nonErrorProblems : argv . nonErrorProblems as ProblemKind [ ] ,
306
+ } )
0 commit comments