How to use the jsonfile.writeFileSync function in jsonfile

To help you get started, we’ve selected a few jsonfile 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 SAP / chevrotain / scripts / pre_release_build.js View on Github external
)
    process.exit(-1)
}

var oldVersion = config.currVersion
var newVersion = semver.inc(config.currVersion, config.mode)

var bumpedPkgJson = _.clone(config.pkgJson)
bumpedPkgJson.version = newVersion
var oldVersionRegExpGlobal = new RegExp(oldVersion, "g")
var bumpedApiString = config.apiString.replace(
    oldVersionRegExpGlobal,
    newVersion
)

jf.writeFileSync(config.packagePath, bumpedPkgJson, { spaces: 2 })
fs.writeFileSync(config.versionPath, bumpedApiString)

// updating CHANGELOG.md date
var nowDate = new Date()
var nowDateString = nowDate.toLocaleDateString("en-US").replace(/\//g, "-")
var changeLogDate = config.changeLogString.replace(
    dateTemplateRegExp,
    "## " + newVersion + " " + "(" + nowDateString + ")"
)
fs.writeFileSync(config.changeLogPath, changeLogDate)

var docsOldVersionRegExp = new RegExp(oldVersion.replace(/\./g, "_"), "g")
_.forEach(config.docFilesPaths, function(currDocPath) {
    console.log("bumping file: <" + currDocPath + ">")
    var currItemContents = fs.readFileSync(currDocPath, "utf8").toString()
    var bumpedItemContents = currItemContents.replace(
github mukesh-kumar1905 / al / lib / tasks / addp.js View on Github external
export default function(path){
  // add path to current paths
  const paths = json.readFileSync(join(cwd, 'path.json'));
  if (paths.indexOf(path) !== -1){
    console.log(red(`Path ${path} already exists in paths`));
    return;
  }
  paths.push(path);
  json.writeFileSync(join(cwd, 'path.json'), paths, {spaces: 2});

  // give instruction on how to load
  console.log(yellow(`Added ${path} to paths config`));
  console.log(`Run ${green('al load')} to load config`);
}
github Esri / arcgis-rest-js / demos / ago-node-cli / lib / item-export-command.js View on Github external
.then((maybeData) => {
      if (maybeData) {
        model.data = maybeData;
      }
      // now write out the file...
      jsonfile.writeFileSync(fileName, model,  {spaces: 2});
      console.info(`Done. Exported "${model.item.title}" to ${fileName}`);
    })
    .catch((err) => {
github roccomuso / node-webhooks / index.js View on Github external
function _initDB (file) {
  // init DB.
  var db = {} // init empty db
  jsonfile.writeFileSync(file, db, {spaces: 2})
}
github vervallsweg / cast-web-api / lib / config / assistant-setup.js View on Github external
return new Promise(resolve => {
            let file = AssistantSetup.getAbsolutePath()+'/config/client_secret.json';

            jsonfile.writeFileSync(file, object, function (err) {
                if (err) {
                    console.log('writeClientSecretJSON error: '+err)
                }
            });
            resolve(true);
        });
    }
github microsoft / azure-devops-extension-tasks / scripts / setTaskVersion.js View on Github external
taskJsonFiles.forEach(function(taskJsonFile) {
        console.log("Updating: " + taskJsonFile);
        if (fs.existsSync(taskJsonFile)) {
            var task = jsonfile.readFileSync(taskJsonFile);
    
            task["version"] = newVersion;
    
            jsonfile.writeFileSync(taskJsonFile, task, {spaces: 2, EOL: '\r\n'});
        }
    });
});
github DivanteLtd / magento1-vsbridge / node-app / src / index.js View on Github external
function recreateTempIndex() {

    let indexMeta = readIndexMeta()

    try { 
        indexMeta.version ++
        INDEX_VERSION = indexMeta.version
        indexMeta.updated = new Date()
        jsonFile.writeFileSync(INDEX_META_PATH, indexMeta)
    } catch (err) {
        console.error(err)
    }

    let step2 = () => { 
        client.indices.create({ index: `${config.elasticsearch.indexName}_${INDEX_VERSION}` }).then(result=>{
            console.log('Index Created', result)
            console.log('** NEW INDEX VERSION', INDEX_VERSION, INDEX_META_DATA.created)
        }).then((result) => {
            putMappings(client, `${config.elasticsearch.indexName}_${INDEX_VERSION}`, ()  => {})
        })
    }


    return client.indices.delete({
        index: `${config.elasticsearch.indexName}_${INDEX_VERSION}`
github gajus / brim / gulpfile.js View on Github external
.src('./dist/' + pkg.name + '.js')
        .pipe(header(distHeader))
        .pipe(gulp.dest('./dist/'))
        .pipe(uglify())
        .pipe(rename(pkg.name + '.min.js'))
        .pipe(header(distHeader))
        .pipe(gulp.dest('./dist/'));

    bower.name = pkg.name;
    bower.description = pkg.description;
    bower.version = pkg.version;
    bower.keywords = pkg.keywords;
    bower.license = pkg.license;
    bower.authors = [pkg.author];

    jsonfile.writeFileSync('./bower.json', bower);
});
github webextensions / live-css-editor / extension / manifest-generator.js View on Github external
manifest["-ms-preload"] = {
            "backgroundScript": "backgroundScriptsAPIBridge.js",
            "contentScript": "contentScriptsAPIBridge.js"
        };
    }

    var targetFileName;
    switch (whichBrowser) {
        case "chrome":  targetFileName = "manifest-chrome.json";  break;
        case "edge":    targetFileName = "manifest-edge.json";    break;
        case "firefox": targetFileName = "manifest-firefox.json"; break;
        case "opera":   targetFileName = "manifest-opera.json";   break;
        default:        targetFileName = "manifest.json";         break;
    }
    process.stdout.write("Generating " + targetFileName + " : ");
    jsonfile.writeFileSync(path.join(__dirname, targetFileName), manifest, {spaces: 4});
    process.stdout.write(chalk.green(" ✓") + "\n");
};
github devbridge / Styleguide / routes / snippets.js View on Github external
newSnippet = {
    id: id,
    name: req.body.name,
    code: req.body.code,
    description: req.body.description,
    inlineCss: req.body.inlineCss,
    includeJs: req.body.includeJs,
    isEdited: false,
    isDeleted: false
  };

  dataStore.push(newSnippet);
  uniques.push(id);

  jf.writeFileSync(dataPath, dataStore);
  jf.writeFileSync(config.uniques, uniques);

  newSnippet.category = Number(req.body.category);
  res.json(newSnippet);
});