Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
if (force) {
cleanConfigRequireCache(cwd);
}
let config = null;
const relativeFile = file.replace(`${paths.cwd}/`, '');
this.relativeFile = relativeFile;
const onError = (e, file) => {
const msg = `配置文件 "${file.replace(`${paths.cwd}/`, '')}" 解析出错,请检查语法。
\r\n${e.toString()}`;
this.printError(msg);
throw e;
};
config = getConfigByConfigFile(file, {
defaultConfig,
onError,
});
config = this.service.applyPlugins('_modifyConfig', {
initialValue: config,
});
// Validate
for (const plugin of this.plugins) {
const { name, validate } = plugin;
if (config[name] && validate) {
try {
plugin.validate.call({ cwd }, config[name]);
} catch (e) {
// 校验出错后要把值设到缓存的 config 里,确保 watch 判断时才能拿到正确的值