Skip to content

Commit

Permalink
Improve --max-issues and --no-progress handling
Browse files Browse the repository at this point in the history
  • Loading branch information
webpro committed Oct 10, 2022
1 parent 0e977e3 commit 984fc5a
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions src/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { printHelp } from './help';
import { importConfig, resolveConfig, resolveIncludedFromArgs } from './util/config';
import reporters from './reporters';
import { run } from '.';
import type { Configuration } from './types';
import type { Configuration, IssueGroup } from './types';

const {
values: {
Expand All @@ -18,7 +18,7 @@ const {
'no-progress': noProgress = false,
reporter = 'symbols',
jsdoc = [],
'max-issues': maxIssues = '1',
'max-issues': maxIssues = '0',
},
} = parseArgs({
options: {
Expand Down Expand Up @@ -48,7 +48,8 @@ if (!configuration) {
process.exit(1);
}

const isShowProgress = noProgress !== false || (process.stdout.isTTY && typeof process.stdout.cursorTo === 'function');
const isShowProgress =
noProgress === false ? process.stdout.isTTY && typeof process.stdout.cursorTo === 'function' : !noProgress;

const report =
reporter in reporters ? reporters[reporter as keyof typeof reporters] : require(path.join(cwd, reporter));
Expand All @@ -74,7 +75,11 @@ const main = async () => {

report({ issues, cwd, config });

if (counters.files > Number(maxIssues)) process.exit(counters.files);
const group = include.files ? 'files' : (Object.keys(include) as IssueGroup[]).find(key => include[key]);
if (group) {
const count = counters[group];
if (count > Number(maxIssues)) process.exit(count);
}
};

main();

0 comments on commit 984fc5a

Please sign in to comment.