Skip to content

Commit

Permalink
.cjs file support for config files
Browse files Browse the repository at this point in the history
  • Loading branch information
sanex3339 committed Feb 12, 2022
1 parent 92535aa commit 496a610
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 2 deletions.
1 change: 0 additions & 1 deletion src/cli/utils/CLIUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ export class CLIUtils {
public static readonly allowedConfigFileExtensions: string[] = [
'.js',
'.json',
'.mjs',
'.cjs'
];

Expand Down
6 changes: 6 additions & 0 deletions test/fixtures/config.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
module.exports = {
compact: true,
exclude: ['**/foo.js'],
selfDefending: false,
sourceMap: true
};
24 changes: 23 additions & 1 deletion test/unit-tests/cli/utils/CLIUtils.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,29 @@ describe('CLIUtils', () => {
});
});

describe('Variant #2: json file with config', () => {
describe('Variant #2: cjs file with config', () => {
const configDirName: string = 'test/fixtures';
const configFileName: string = 'config.cjs';
const configFilePath: string = `../../../${configDirName}/${configFileName}`;
const expectedResult: TInputOptions = {
compact: true,
exclude: ['**/foo.js'],
selfDefending: false,
sourceMap: true
};

let result: Object;

before(() => {
result = CLIUtils.getUserConfig(configFilePath);
});

it('should return object with user configuration', () => {
assert.deepEqual(result, expectedResult);
});
});

describe('Variant #3: json file with config', () => {
const configDirName: string = 'test/fixtures';
const configFileName: string = 'config.json';
const configFilePath: string = `../../../${configDirName}/${configFileName}`;
Expand Down

0 comments on commit 496a610

Please sign in to comment.