Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
// ignoring them. In the future, promise rejections that are not handled will
// terminate the Node.js process with a non-zero exit code.
process.on("unhandledRejection", err => {
throw err;
});
if (argv.config === undefined) {
console.log("Please provide a configuration file as input with the --config parameter.")
process.exit(1);
}
var file = argv.config;
var mergedOutput = mergeJson(file);
delete mergedOutput.extends;
var mergedString = json.stringify(mergedOutput, null, 2);
if (argv.out === undefined) {
console.log(mergedString);
}
else {
fs.writeFileSync(argv.out, mergedString);
}
function mergeJson(jsonFilePath) {
var jsonFile = json.parse(fs.readFileSync(jsonFilePath).toString(), null, true);
if (jsonFile.extends !== undefined && typeof jsonFile.extends === "string") {
var baseFileName = path.resolve(path.dirname(jsonFilePath), jsonFile.extends)
if (!fs.existsSync(baseFileName)) {
baseFileName = path.resolve(path.dirname(jsonFilePath), path.join("node_modules", jsonFile.extends));
}
return arr1;
}
var mergedConfigs = configs[0];
configs.slice(1).forEach(function (config) {
mergedConfigs = arrayMergeRecursive(mergedConfigs, config);
});
// Save merged configs
if (verbose) {
console.log('Output file ' + outputfile);
}
var output = json.stringify(mergedConfigs, null, 4);
output += '\n';
fs.writeFileSync(outputfile, output);
.then(() => fs.writeFile(filename, json.stringify(settings, null, 4)))
.then(() => settings);
() => json.stringify(defaultSettingsWithComments, null, 4)
)
async function processFile(fileInfo: FileInfo, configInfo: ConfigInfo): Promise {
const settingsFromCommandLine = util.clean({
languageId: cfg.options.languageId || undefined,
language: cfg.local || undefined,
});
const { filename, text } = fileInfo;
const info = calcFinalConfigInfo(configInfo, settingsFromCommandLine, filename, text);
const config = info.configInfo.config;
const source = info.configInfo.source;
cfg.debug(`Filename: ${filename}, Extension: ${path.extname(filename)}, LanguageIds: ${info.languageIds.toString()}`);
if (!info.configInfo.config.enabled) return 0;
const debugCfg = { config: {...config, source: null}, source };
cfg.debug(commentJson.stringify(debugCfg, undefined, 2));
const startTime = Date.now();
const wordOffsets = await cspell.validateText(text, info.configInfo.config);
const issues = cspell.Text.calculateTextDocumentOffsets(filename, text, wordOffsets);
const elapsed = (Date.now() - startTime) / 1000.0;
const dictionaries = config.dictionaries || [];
cfg.info(
`Checking: ${filename}, File type: ${config.languageId}, Language: ${config.language} ... Issues: ${issues.length} ${elapsed}S`,
MessageTypes.Info
);
cfg.info(`Dictionaries Used: ${dictionaries.join(', ')}`, MessageTypes.Info);
issues
.filter(cfg.uniqueFilter)
.forEach((issue) => cfg.logIssue(issue));
return issues.length;
}
return this.withLoader('Init Typescript stuff', async () => {
await this.runCommand('yarn tsc --init')
const configFile = path.join(this.cwd, 'tsconfig.json')
const src = path.join(this.cwd, 'src')
const config = json.parse(fs.readFileSync(configFile, { encoding: 'utf8' }), undefined, true)
set(config, 'extends', BEARER_TSCONFIG)
fs.writeFileSync(configFile, json.stringify(config, null, 2))
if (!fs.existsSync(src)) {
fs.mkdirSync(src)
fs.writeFileSync(path.join(src, 'index.ts'), '')
}
})
}
export function stringifyJson(obj: any): string {
return json.stringify(obj, null, 4);
}
save() {
const content = commentsJson.stringify(json, null, file.getIndent());
file.save(content);
return this;
},