Skip to content

Commit

Permalink
Fix running xo --print-config without a filename (#587)
Browse files Browse the repository at this point in the history
  • Loading branch information
fisker committed Aug 8, 2021
1 parent 68cb5ab commit 5ff95ad
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
4 changes: 2 additions & 2 deletions cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -173,8 +173,8 @@ if (options.nodeVersion) {
}

(async () => {
if (options.printConfig) {
if (input.length > 0) {
if (typeof options.printConfig === 'string') {
if (input.length > 0 || options.printConfig === '') {
console.error('The `--print-config` flag must be used with exactly one filename');
process.exit(1);
}
Expand Down
7 changes: 7 additions & 0 deletions test/cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -190,3 +190,10 @@ test('print-config flag requires a single filename', async t => {
);
t.is(error.stderr.trim(), 'The `--print-config` flag must be used with exactly one filename');
});

test('print-config flag without filename', async t => {
const error = await t.throwsAsync(() =>
main(['--print-config']),
);
t.is(error.stderr.trim(), 'The `--print-config` flag must be used with exactly one filename');
});

0 comments on commit 5ff95ad

Please sign in to comment.