Skip to content

Commit

Permalink
feat: add --quiet flag to suppress No depcheck issue messages
Browse files Browse the repository at this point in the history
Closes #759
  • Loading branch information
openam committed Aug 24, 2023
1 parent 520b841 commit 9bb4931
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 1 deletion.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,8 @@ All of the arguments are optional:

`--ignore-patterns`: Comma separated patterns describing files to ignore. Patterns must match the .gitignore [spec](http://git-scm.com/docs/gitignore). Example, `--ignore-patterns=build/Release,dist,coverage,*.log`.

`--quiet`: Suppress the "No depcheck issue" log. Useful in a monorepo with multiple packages to focus only on packages with issues.

`--help`: Show the help message.

`--parsers`, `--detectors` and `--specials`: These arguments are for advanced usage. They provide an easy way to customize the file parser and dependency detection. Check [the pluggable design document](https://github.com/depcheck/depcheck/blob/master/doc/pluggable-design.md) for more information.
Expand Down
2 changes: 1 addition & 1 deletion src/cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ function print(result, log, opt, rootDir) {
lodash.isError(value) ? value.stack : value,
),
);
} else if (noIssue(result)) {
} else if (noIssue(result) && !opt.quiet) {
log('No depcheck issue');
} else {
const deps = prettify(
Expand Down
1 change: 1 addition & 0 deletions src/utils/configuration-reader.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ export function getCliArgs(args, version) {
'Comma separated patterns describing files to ignore.',
)
.describe('parsers', 'Comma separated glob:parser pair list')
.describe('quiet', 'Suppress the "No depcheck issue" message')
.describe('detectors', 'Comma separated detector list')
.describe('specials', 'Comma separated special parser list')
.version('version', 'Show version number', version)
Expand Down
13 changes: 13 additions & 0 deletions test/cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@ function makeArgv(module, options) {
argv.push('--json');
}

if (options.quiet) {
argv.push('--quiet');
}

if (typeof options.ignoreBinPackage !== 'undefined') {
argv.push(`--ignore-bin-package=${options.ignoreBinPackage}`);
}
Expand Down Expand Up @@ -162,6 +166,15 @@ describe('depcheck command line', () => {
},
));

it('should output no depcheck issue when happen', () =>
testCli(makeArgv('good', { quiet: true })).then(
({ log, error, exitCode }) => {
log.should.equal('');
error.should.be.empty();
exitCode.should.equal(0);
},
));

it('should output unused dependencies', () =>
testCli(makeArgv('bad', {})).then(({ logs, error, exitCode }) => {
logs.should.have.length(2);
Expand Down

0 comments on commit 9bb4931

Please sign in to comment.