Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
fs.accessSync(projectConfigFile, fs.R_OK);
const projectConfig = markdownlint.readConfigSync(projectConfigFile, configFileParsers);
config = extend(config, projectConfig);
break;
} catch (error) {
// Ignore failure
}
}
// Normally parsing this file is not needed,
// because it is already parsed by rc package.
// However I have to do it to overwrite configuration
// from .markdownlint.{json,yaml,yml}.
if (userConfigFile) {
try {
const userConfig = markdownlint.readConfigSync(userConfigFile, configFileParsers);
config = extend(config, userConfig);
} catch (error) {
console.warn('Cannot read or parse config file ' + args.config + ': ' + error.message);
}
}
return config;
}
function readConfiguration(args) {
let config = rc('markdownlint', {});
const userConfigFile = args.config;
for (const projectConfigFile of projectConfigFiles) {
try {
fs.accessSync(projectConfigFile, fs.R_OK);
const projectConfig = markdownlint.readConfigSync(projectConfigFile, configFileParsers);
config = extend(config, projectConfig);
break;
} catch (error) {
// Ignore failure
}
}
// Normally parsing this file is not needed,
// because it is already parsed by rc package.
// However I have to do it to overwrite configuration
// from .markdownlint.{json,yaml,yml}.
if (userConfigFile) {
try {
const userConfig = markdownlint.readConfigSync(userConfigFile, configFileParsers);
config = extend(config, userConfig);
} catch (error) {
while (vscode.workspace.getWorkspaceFolder(vscode.Uri.file(dir))) {
workspaceDetail = "no configuration file in workspace folder";
// Use cached configuration if present for directory
if (configMap[dir]) {
return configMap[dir];
}
if (configMap[dir] === undefined) {
// Look for config file in current directory
for (const configFileName of configFileNames) {
const configFilePath = path.join(dir, configFileName);
if (fs.existsSync(configFilePath)) {
outputLine("INFO: Loading custom configuration from \"" + configFilePath +
"\", overrides user/workspace/custom configuration for directory and its children.");
try {
return (configMap[dir] = {
"config": markdownlint.readConfigSync(configFilePath, configParsers),
"source": configFilePath
});
} catch (ex) {
outputLine("ERROR: Unable to read configuration file \"" +
configFilePath + "\" (" + (ex.message || ex.toString()) + ").", true);
}
}
}
// Remember missing or invalid file
configMap[dir] = null;
}
const parent = path.dirname(dir);
// Move to parent directory, stop if no parent
if (dir === parent) {
break;
}
const userWorkspaceConfigMetadata = configuration.inspect(sectionConfig);
let source = null;
if (userWorkspaceConfigMetadata.workspaceFolderValue && (vscode.workspace.workspaceFolders.length > 1)) {
// Length check to work around https://github.com/Microsoft/vscode/issues/34386
source = openFolderSettingsCommand;
} else if (userWorkspaceConfigMetadata.workspaceValue) {
source = openWorkspaceSettingsCommand;
} else if (userWorkspaceConfigMetadata.globalValue) {
source = openGlobalSettingsCommand;
}
// Bootstrap extend behavior into readConfigSync
if (userWorkspaceConfig && userWorkspaceConfig.extends) {
const extendPath = path.resolve(require("os").homedir(), userWorkspaceConfig.extends);
try {
const extendConfig = markdownlint.readConfigSync(extendPath, configParsers);
userWorkspaceConfig = {
...extendConfig,
...userWorkspaceConfig
};
} catch (ex) {
outputLine("ERROR: Unable to extend configuration file \"" +
extendPath + "\" (" + (ex.message || ex.toString()) + ").", true);
}
}
return (configMap[name] = {
"config": userWorkspaceConfig,
source
});
}