Skip to content

Commit

Permalink
Fix the extensions option (#503)
Browse files Browse the repository at this point in the history
  • Loading branch information
privatenumber committed Nov 2, 2020
1 parent 2346fef commit 35e6336
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/options-manager.js
Expand Up @@ -243,7 +243,7 @@ const mergeOptions = (options, xoOptions = {}, enginesOptions = {}) => {
...options
});

mergedOptions.extensions = DEFAULT_EXTENSION.concat(options.extensions || []);
mergedOptions.extensions = DEFAULT_EXTENSION.concat(mergedOptions.extensions || []);
mergedOptions.ignores = getIgnores(mergedOptions);

return mergedOptions;
Expand Down
9 changes: 9 additions & 0 deletions test/cli-main.js
Expand Up @@ -158,3 +158,12 @@ test('space option with boolean strings', async t => {
t.true(trueResult.stdout.includes('Expected indentation of 2 spaces'));
t.true(falseResult.stdout.includes('Expected indentation of 1 tab'));
});

test('extension option', async t => {
const cwd = path.join(__dirname, 'fixtures/custom-extension');
const {stdout} = await t.throwsAsync(main(['--reporter=json', '--extension=mjs'], {cwd}));
const reports = JSON.parse(stdout);

t.is(reports.length, 1);
t.true(reports[0].filePath.endsWith('.mjs'));
});
3 changes: 3 additions & 0 deletions test/fixtures/custom-extension/one-space.mjs
@@ -0,0 +1,3 @@
console.log([
1
]);

0 comments on commit 35e6336

Please sign in to comment.