How to use the comment-json.stringify function in comment-json

To help you get started, weā€™ve selected a few comment-json examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github imodeljs / imodeljs / tools / build / scripts / printconfig.js View on Github external
// 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));
    }
github girder / girder / scripts / json_config_merge.js View on Github external
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);
github streetsidesoftware / vscode-spell-checker / packages / client / src / settings / CSpellSettings.ts View on Github external
        .then(() => fs.writeFile(filename, json.stringify(settings, null, 4)))
        .then(() => settings);
github streetsidesoftware / cspell / packages / cspell / src / application.ts View on Github external
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;
    }
github Bearer / bearer-js / packages / package-init / src / index.ts View on Github external
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'), '')
      }
    })
  }
github golf1052 / code-sync / src / helpers.ts View on Github external
export function stringifyJson(obj: any): string {
    return json.stringify(obj, null, 4);
}
github sapegin / mrm-core / src / formats / json.js View on Github external
save() {
			const content = commentsJson.stringify(json, null, file.getIndent());
			file.save(content);
			return this;
		},

comment-json

Parse and stringify JSON with comments. It will retain comments even after saved!

MIT
Latest version published 23 days ago

Package Health Score

83 / 100
Full package analysis

Popular comment-json functions