Skip to content

Commit 7613e58

Browse files
refactor to leverage require(esm)
1 parent 1b8b91d commit 7613e58

File tree

1 file changed

+3
-5
lines changed

1 file changed

+3
-5
lines changed

lib/cli/config.js

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -65,18 +65,16 @@ const parsers = (exports.parsers = {
6565
* @returns {Object} Parsed config object
6666
*/
6767
exports.loadConfig = filepath => {
68-
const packageJson = require(path.resolve(utils.cwd(), 'package.json'));
6968
let config = {};
7069
debug('loadConfig: trying to parse config at %s', filepath);
7170

7271
const ext = path.extname(filepath);
7372
try {
7473
if (ext === '.yml' || ext === '.yaml') {
7574
config = parsers.yaml(filepath);
76-
} else if ((ext === '.js' && packageJson.type === "module") || ext === '.mjs') {
77-
config = parsers.js(filepath).default;
78-
} else if (ext === '.js' || ext === '.cjs') {
79-
config = parsers.js(filepath);
75+
} else if (ext === '.js' || ext === '.cjs' || ext === '.mjs') {
76+
const parsedConfig = parsers.js(filepath);
77+
config = parsedConfig.default ?? parsedConfig;
8078
} else {
8179
config = parsers.json(filepath);
8280
}

0 commit comments

Comments
 (0)