Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
async function run(): Promise {
header();
const configFiles = (await globP(cfg.configGlob, cfg.configGlobOptions)).filter(util.uniqueFn());
cfg.info(`Config Files Found:\n ${configFiles.join('\n ')}\n`, MessageTypes.Info);
const config = cspell.readSettingsFiles(configFiles);
const configInfo: ConfigInfo = { source: configFiles.join(' || '), config };
// Get Exclusions from the config files.
const { root } = cfg;
const globOptions = { root, cwd: root };
const exclusionGlobs = extractGlobExcludesFromConfig(root, configInfo.source, configInfo.config).concat(cfg.excludes);
const files = filterFiles(await findFiles(cfg.files, globOptions), exclusionGlobs);
return processFiles(fileLoader(files), configInfo);
}
private resolveConfigImports(config: CSpellUserSettings, folderUri: string): CSpellUserSettings {
const uriFsPath = Uri.parse(folderUri).fsPath;
const imports = typeof config.import === 'string' ? [config.import] : config.import || [];
if (!imports.length) {
return config;
}
const importAbsPath = imports.map(file => path.resolve(file, uriFsPath));
return CSpell.mergeSettings(CSpell.readSettingsFiles(importAbsPath), config);
}
}
function readSettingsFiles(paths: string[]) {
log(`readSettingsFiles:`, paths);
const existingPaths = paths.filter(filename => fs.existsSync(filename));
return CSpell.readSettingsFiles(existingPaths);
}
private _importSettings() {
log(`importSettings`);
const importPaths = [...this.configsToImport.keys()].sort();
return CSpell.readSettingsFiles(importPaths);
}
const pSettings = globP(configGlob, configGlobOptions).then(filenames => ({source: filenames[0], config: cspell.readSettingsFiles(filenames)}));
const [foundSettings, text] = await Promise.all([pSettings, readFile(filename)]);