diff --git a/configent.js b/configent.js index e066027..474b1ac 100644 --- a/configent.js +++ b/configent.js @@ -112,12 +112,18 @@ function configent(defaults, input = {}, configentOptions) { Object.assign(pkgjson.dependencies, pkgjson.devDependencies) const unsortedConfigTemplates = readdirSync(resolve(getParentModuleDir(), detectDefaultsConfigPath)) - .map(file => ({ - file, - ...require(resolve(getParentModuleDir(), detectDefaultsConfigPath, file)) - })) + .map(file => { + try { + return {file, ...require(resolve(getParentModuleDir(), detectDefaultsConfigPath, file))} + } catch (err) { + } + }) + .filter(template => { + return template?.file?.indexOf('.config.js') > 0 + && template.condition && template.condition({ pkgjson }) + }) + const configTemplates = sortBySupersedings(unsortedConfigTemplates) - .filter(configTemplate => configTemplate.condition({ pkgjson })) .reverse() if (configTemplates) { if (configTemplates.length > 1) // we don't care about the default template @@ -185,4 +191,4 @@ function missingModuleError(modules) { ...paths.map(p => '- ' + p), `Updating the packages may fix the problem.`, '' ].join('\n')) -} \ No newline at end of file +}