Skip to content

Commit 496a610

Browse files
committed
.cjs file support for config files
1 parent 92535aa commit 496a610

File tree

3 files changed

+29
-2
lines changed

3 files changed

+29
-2
lines changed

src/cli/utils/CLIUtils.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ export class CLIUtils {
1111
public static readonly allowedConfigFileExtensions: string[] = [
1212
'.js',
1313
'.json',
14-
'.mjs',
1514
'.cjs'
1615
];
1716

test/fixtures/config.cjs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
module.exports = {
2+
compact: true,
3+
exclude: ['**/foo.js'],
4+
selfDefending: false,
5+
sourceMap: true
6+
};

test/unit-tests/cli/utils/CLIUtils.spec.ts

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,29 @@ describe('CLIUtils', () => {
3131
});
3232
});
3333

34-
describe('Variant #2: json file with config', () => {
34+
describe('Variant #2: cjs file with config', () => {
35+
const configDirName: string = 'test/fixtures';
36+
const configFileName: string = 'config.cjs';
37+
const configFilePath: string = `../../../${configDirName}/${configFileName}`;
38+
const expectedResult: TInputOptions = {
39+
compact: true,
40+
exclude: ['**/foo.js'],
41+
selfDefending: false,
42+
sourceMap: true
43+
};
44+
45+
let result: Object;
46+
47+
before(() => {
48+
result = CLIUtils.getUserConfig(configFilePath);
49+
});
50+
51+
it('should return object with user configuration', () => {
52+
assert.deepEqual(result, expectedResult);
53+
});
54+
});
55+
56+
describe('Variant #3: json file with config', () => {
3557
const configDirName: string = 'test/fixtures';
3658
const configFileName: string = 'config.json';
3759
const configFilePath: string = `../../../${configDirName}/${configFileName}`;

0 commit comments

Comments
 (0)