How to use the jsonfile.readFile 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
function checkSchedule() {
    console.log('checking schedule...');

    // READ SCHEDULE JSON //
    jsonfile.readFile(file, function(err, obj) {
        if (err) {
            console.log('schedule read error');
        } else {


            // IF WE'RE DUE A NEW SCHEDULE WINDOW //
            var time = new Date();
            var rescheduling = false;
            if (obj.reschedule) {
                var rescheduleTime = new Date(obj.reschedule);
                if (time > rescheduleTime) {
                    rescheduling = true;
                }
            } else {
                console.log('obj.reschedule not found');
                rescheduling = true;
github SteeltoeOSS / Steeltoe / scripts / patch-project-json.js View on Github external
var buildNumber = version.substring(lastDash + 1, version.length);
var num = "00000000" + parseInt(buildNumber);
buildNumber = num.substr(num.length-5);  

var dependsVersion = version.substring(0, lastDash) + '-*';
    
if (tag) {
    // Turn version into tag, dependsVersion = version
    version = tag;
    dependsVersion = version;
} else {
    version = version.substring(0, lastDash) + '-' + buildNumber;
}    
    

jsonfile.readFile(file, function (err, project) {
    
    if (err)
        console.error(err);

    console.log("Version: " + version);
    console.log("Dependency Version: " + dependsVersion);
    
    // Patch the project.version 
    project.version = version;

    // Patch dependencies
    if (project.dependencies['Steeltoe.CloudFoundry.Connector'] ) {
        project.dependencies['Steeltoe.CloudFoundry.Connector'] = dependsVersion;
    }

    if (project.dependencies['Steeltoe.Extensions.Configuration.CloudFoundry']) {
github roccomuso / node-webhooks / index.js View on Github external
return new Promise(function (resolve, reject) {
    if (self.isMemDb) resolve(self.db)
    jsonfile.readFile(self.db, function (err, obj) {
      if (err) {
        reject(err) // file not found
      } else {
        resolve(obj) // file exists
      }
    })
  })
}
github orchoban / react.cordova / node_modules / .cache / esm / f1f70fc214a5a573.js View on Github external
fs.writeFile(dir + "/react-js/public/index.html", dataString, function (err) {
                if (err) {
                    return console.log(err);
                } else {
                    console.log(dir + "/react-js/public/index.html ready to by mobile app with cordova");

                    //-- react package.json --//
                    const jsonfile = require('jsonfile');
                    const file = dir + '/react-js/package.json';
                    jsonfile.readFile(file)
                        .then(obj => {

                            obj.homepage = "./";
                            jsonfile.writeFile(file, obj, function (err) {
                                if (err) {
                                    console.error("ERROR: add homepage to react package.json . ", err);
                                    return;
                                } else {
                                    console.log("updete homepage in react-js package.json , now it's ready to by mobile app with cordova.");
                                    reco.replaceWwwRootDir(dir + '/cordova/www');
                                }
                            })
                        })
                        .catch(error => {
                            reco.setState({ error: true });
                            console.error("reco-cli-recoFiles=> ERROR: ", error);
github vocol / vocol / routes / index.js View on Github external
fs.exists(path, function(exists) {
            var data = fs.readFileSync(path);
            if (exists && data.includes('vocabularyName')) {
              jsonfile.readFile(path, function(err, obj{
                if (err)
                  console.log(err); 
                if (obj.hasOwnProperty('text'))
                  res.render('index', {
                    title: 'Home',
                    metaData: str,
                    homePage: obj.text
                  });
              });
            }
          });
        });
github jsdevkr / axui-datagrid / scripts / syncVersion.js View on Github external
const path = require('path');
const jsonfile = require('jsonfile');

jsonfile
  .readFile('./src/package.json')
  .then(json => {
    console.dir(`update version to "${json.version}"`);

    jsonfile
      .writeFile('./dist/package.json', json, {
        spaces: 2,
        EOL: '\r\n',
      })
      .then(res => {
        console.log('Write complete : dist/package.json');
      });

    jsonfile.readFile('./package.json').then(obj => {
      obj.version = json.version;
      jsonfile
github Sanjit1 / WizardMirror / apps / time / time.js View on Github external
function time() {
    const jsonfile = require('jsonfile');
    jsonfile.readFile("apps.json", function (err, obj) {
        if (err) console.error(err);
        const appList = obj.apps;
        for (let i = 0; i < appList.length; i++) {
            if (appList[i].name == "Time") {
                const dta = obj.apps[i].config;
                const timeDiv = document.getElementById(dta.div);
                const showSeconds = dta.showseconds;
                const twentyFourHourClock = dta.twentyfourhourclock;

                var date = new Date();
                var dayList = ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"];
                var day = dayList[date.getDay()];
                var monthList = ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"];
                var month = monthList[date.getMonth()];
                var year = date.getFullYear();
                var dateNumb = date.getDate();
github GSA / code-gov-harvester-deprecated / index.js View on Github external
})

      reporter.writeReportToFile()

      logger.info('[FINISHED]: Code.json processing')
    })
    .catch(function (err) {
      logger.error(err)
    })
    
}

logger.info('[STARTED]: Code.json processing')

const reporter = new Reporter({REPORT_FILEPATH: './data/report.json'}, logger)
JsonFile.readFile('./data/agencyMetadata.json', (error, agencies) => {
  main(agencies, reporter)
})