Skip to content

Commit a058d8d

Browse files
committed
Add CLI flag to treat ATTW problems as non-errors
1 parent 1c7a705 commit a058d8d

File tree

1 file changed

+41
-3
lines changed
  • examples/publish-ci/are-the-types-wrong

1 file changed

+41
-3
lines changed

examples/publish-ci/are-the-types-wrong/main.tsx

Lines changed: 41 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import {
1616
} from '@arethetypeswrong/core'
1717
import React from 'react'
1818
import { render, Text, Box, Static } from 'ink'
19+
import yargs from 'yargs/yargs'
1920

2021
const allResolutionKinds: ResolutionKind[] = [
2122
'node10',
@@ -232,7 +233,18 @@ function ChecksTable(props: { checks?: Checks }) {
232233
)
233234
}
234235

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) {
236248
const analysis = await checkTgz(rtkPackageTgzBytes)
237249

238250
const checks: Checks = {
@@ -263,6 +275,32 @@ function ChecksTable(props: { checks?: Checks }) {
263275
</Static>
264276
)
265277

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
267303
process.exit(exitCode)
268-
})()
304+
})({
305+
nonErrorProblems: argv.nonErrorProblems as ProblemKind[],
306+
})

0 commit comments

Comments
 (0)