How to use the jsonfile.writeFile 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 Whitevinyl / ARP / js / node / _SCHEDULER.js View on Github external
else {
                    t = timeSlot('day');
                }
                ev = {
                    action: action,
                    time: t + (dayTime*h)
                };
                events.push(ev);
            }
        }
    }


    // WRITE IT //
    var s = writeSchedule(time,events);
    jsonfile.writeFile(file, s, function(err) {
        if (err) {
            console.log("failed to write new schedule window");
        } else {
            console.log("written new schedule window");
        }
    });
}
github bikenik / alfred-anki / src / cmd / refresh.js View on Github external
let countFormat = elem.length.toString()
		let countNew = elem.filter(x => x).length.toString()
		while (countFormat.length <= 10) {
			countFormat += '  '
		}

		while (countNew.length <= 10) {
			countNew += '  '
		}

		cards2Json[`${ankiDecks[i]}`] = `\tCards: ${countFormat}New: ${countNew}Due: ${ankiCardsCount[i].length - elem
			.filter(x => x).length}\t\t${elem2.filter(x => x).length > 0 ? ` Suspend: ${elem2.filter(x => x).length}` : ''}`
	}

	/* eslint-enable no-await-in-loop */
	jsonfile.writeFile(fileAnkiCards, cards2Json, {
		spaces: 2
	}, error => {
		if (error !== null) {
			process.stderr.write(error)
		}
	})

	jsonfile.writeFile(fileAnkiModels, ankiModels, {
		spaces: 2
	}, error => {
		if (error !== null) {
			process.stderr.write(error)
		}
	})
	alfy.cache.set('refresh-done', true)
}
github gautamsi / ews-javascript-api / scripts / build.js View on Github external
return new Promise(async resolve => {
    const file = 'package.json'
    const obj = await readFile(file).catch(error => console.error(error));
    delete obj.devDependencies;
    delete obj.scripts;
    await writeFile(`${outputDir}/package.json`, obj, { spaces: 4, EOL: os.EOL }).catch(error => console.error(error));
    resolve();
  });
}
github syndesisio / syndesis / ux / connections_icons / svg / update_icons.js View on Github external
.then(deployment => {
      let madeUpdates = false;

      deployment.forEach(obj => {
        if (!(obj.data.connectorId)) {
          return;
        }
        const update = optimized.find(o => o.id == obj.data.connectorId);
        if (update && obj.data.icon !== update.icon) {
          obj.data.icon = update.icon;
          madeUpdates = true;
        }
      })

      if (madeUpdates) {
        jsonfile.writeFile(DEPLOYMENT_JSON, deployment).then(
          () => jq.run('.', DEPLOYMENT_JSON, { sort: true }).then(out => fs.writeFileSync(DEPLOYMENT_JSON, out + '\n'))
        )
        let schemaJava = fs.readFileSync(SCHEMA_JAVA).toString();
        schemaJava = schemaJava.replace(/VERSION = (\d+);/, (match, version) => 'VERSION = ' + (parseInt(version, 10) + 1) + ';');
        fs.writeFileSync(SCHEMA_JAVA, schemaJava);
      }
    })
    .catch(error => console.error(error))
github SixLabors / ImageSharp / build / appveyor-project-version-patch.js View on Github external
jsonfile.readFile(file, function (err, project) {
	project.version = semversion;
	jsonfile.writeFile(file, project, {spaces: 2}, function(err) {
		console.error(err);
	});
})
github Aymkdn / assistant-plugins / index.js View on Github external
saveConfig:function(plugin, config) {
        if (plugin && config) {
          var configuration = require(path.join(dirname,'configuration'));
          configuration.plugins[plugin] = config;
          var jsonfile = require('jsonfile');
          jsonfile.writeFile(path.join(dirname, 'configuration.json'), configuration, {spaces: 2, EOL: '\r\n'}, function(err) {
            if (err) console.error("[assistant-"+plugin+"] Erreur lors de la sauvegarde de la configuration : "+err);
            else console.log("[assistant-"+plugin+"] Configuration sauvegardée.");
          })
        }
      }
    };
github Bitbrackets / bitbrackets_smart_contracts / migrations / 2_deploy_contracts.js View on Github external
console.log(BbRole.address); 
            console.log('\x1b[33m%s\x1b[0m:', 'Set ContestPoolFactory Address');
            console.log(ContestPoolFactory.address);
            console.log('\x1b[33m%s\x1b[0m:', 'Set ResultsLookup Address');
            console.log(ResultsLookup.address);
            console.log('\x1b[33m%s\x1b[0m:', 'Set BbVault Address');
            console.log(BbVault.address);
            console.log('\x1b[33m%s\x1b[0m:', 'Set BBSettings Address');
            console.log(BbSettings.address);
            console.log('\x1b[33m%s\x1b[0m:', 'Set BbUpgrade Address');
            console.log(BbUpgrade.address);
            console.log('\x1b[33m%s\x1b[0m:', 'Set ContestPoolBase Address');
            console.log(ContestPoolBase.address);
            console.log('\x1b[32m%s\x1b[0m', 'Post - Storage Direct Access Removed');

            jsonfile.writeFile(contractsJson, contracts, {spaces: 2, EOL: '\r\n'}, function (err) {
                console.log(`JSON file created at '${contractsJson}'.`);
                console.error("Errors: " + err);
            });

        } catch (error) {
            console.error("Error on deploy: ", error);
        }
        return deployer;
    });
github giper45 / DockerSecurityPlayground / app / util / LabStates.js View on Github external
    (lsf, cb) => jsonfile.writeFile(lsf, newStates, cb)
  ],
github kitze / gtb / src / index.js View on Github external
function initialize() {
  addCliCommands();

  //if gtb-config doesn't exist, create it then read it and parse the cli arguments
  if (_.isUndefined(gtbConfig)) {
    con.log(`Creating gtb-config for the first time...`);
    writeFile(gtbConfigPath, {
      projects: []
    }, jsonFileSettings, () => {
      readGtbConfig();
      parseArguments();
    });
  }
  //if gtb config exists, just parse the arguments
  else {
    parseArguments();
  }
}
github Raathigesh / atmo / packages / app / src / main / messageHandler.ts View on Github external
filename => {
          if (filename) {
            jsonfile.writeFile(filename, arg.spec, function(err) {
              if (!err) {
                event.sender.send("onSaveSuccess", {
                  name: arg.name,
                  path: filename
                });
              }
            });
          }
        }
      );