Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add --quiet flag to suppress No depcheck issue messages #829

Merged
merged 1 commit into from
Aug 24, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 2 additions & 0 deletions README.md
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
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
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
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