Skip to content

Commit 699a82c

Browse files
fiskerdevinrhode2
authored andcommitted
Fix running xo --print-config without a filename (xojs#587)
1 parent 9a9ab2a commit 699a82c

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

cli.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -173,8 +173,8 @@ if (options.nodeVersion) {
173173
}
174174

175175
(async () => {
176-
if (options.printConfig) {
177-
if (input.length > 0) {
176+
if (typeof options.printConfig === 'string') {
177+
if (input.length > 0 || options.printConfig === '') {
178178
console.error('The `--print-config` flag must be used with exactly one filename');
179179
process.exit(1);
180180
}

test/cli.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -190,3 +190,10 @@ test('print-config flag requires a single filename', async t => {
190190
);
191191
t.is(error.stderr.trim(), 'The `--print-config` flag must be used with exactly one filename');
192192
});
193+
194+
test('print-config flag without filename', async t => {
195+
const error = await t.throwsAsync(() =>
196+
main(['--print-config']),
197+
);
198+
t.is(error.stderr.trim(), 'The `--print-config` flag must be used with exactly one filename');
199+
});

0 commit comments

Comments
 (0)