Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
getConfig(opts = {}) {
const { paths, cwd } = this.service;
const { force, setConfig } = opts;
const defaultConfig = this.service.applyPlugins('modifyDefaultConfig', {
initialValue: {},
});
const file = getConfigFile(cwd);
this.file = file;
if (!file) {
return defaultConfig;
}
// 强制读取,不走 require 缓存
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,