Skip to content

Commit e84a15c

Browse files
committed
Support cjs testem configs
1 parent 7b5f620 commit e84a15c

1 file changed

Lines changed: 4 additions & 1 deletion

File tree

lib/utils/config-reader.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ const yaml = require('js-yaml');
55
const path = require('path');
66
const debug = require('debug')('exam:config-reader');
77

8-
const potentialConfigFiles = ['testem.js', 'testem.json'];
8+
const potentialConfigFiles = ['testem.js', 'testem.json', 'testem.cjs'];
99

1010
/**
1111
* Given an array of file paths, returns the first one that exists and is
@@ -40,11 +40,14 @@ function _readFileByType(file) {
4040
const fileType = file.split('.').pop();
4141
switch (fileType) {
4242
case 'js':
43+
case 'cjs':
4344
return require(file);
4445
case 'json':
4546
return fs.readJsonSync(file);
4647
case 'yaml':
4748
return yaml.load(fs.readFileSync(file));
49+
default:
50+
throw new Error(`Unrecognized file extension for: ${file}`);
4851
}
4952
}
5053
}

0 commit comments

Comments
 (0)