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

Fix running xo --print-config without a filename #587

Merged
merged 1 commit into from
Aug 8, 2021
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
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');
});