How to use the rw.writeFileSync function in rw

To help you get started, we’ve selected a few rw 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 dataproofer / Dataproofer / src / index.js View on Github external
if (program.watch === true || program.suites === true || program.tests === true) {
      process.stderr.write(chalk.red("Error: This feature is not currently implemented"));
      return;
    }
    process.stdout.write(summaryStr);
    // console.log(program);

    var done = function() {
      process.stdout.write("\n### DONE ###");
    };

    var outPath = program.out ? program.out : "/dev/stdout";
    
    if (program.out) resultStr = resultStr.replace(/\[\d+m/g, "");
    if (program.json === true) {
      rw.writeFileSync(outPath, JSON.stringify(results), "utf-8");
      done();
      return;
    }
    if (program.jsonPretty === true) {
      rw.writeFileSync(outPath, JSON.stringify(results, null, 2), "utf-8");
      done();
      return;
    }
    if (program.summary !== true) {
      rw.writeFileSync(outPath, resultStr, "utf-8");
      done();
      return;
    }
  } else {
    process.stderr.write(
      chalk.red("Error: Must use a supported filetype. Currently supported filetypes: " + allowFileExtensions.join(", "), "utf-8")
github interactivethings / galaxy-of-covers / data / js / echonest.js View on Github external
.then(function(data) {
    console.log('Writing to', OUTPUT_FILE);
    rw.writeFileSync(OUTPUT_FILE, JSON.stringify(data, undefined, 2), 'utf8')



    console.log('Writing to', OUTPUT_4WHOSAMPLED_FILE);
    rw.writeFileSync(OUTPUT_4WHOSAMPLED_FILE, csv4Whosampled(data), 'utf8')



  })
  .catch(function(err) {
github interactivethings / galaxy-of-covers / data / js / echonest.js View on Github external
.then(function(data) {
    console.log('Writing to', OUTPUT_FILE);
    rw.writeFileSync(OUTPUT_FILE, JSON.stringify(data, undefined, 2), 'utf8')



    console.log('Writing to', OUTPUT_4WHOSAMPLED_FILE);
    rw.writeFileSync(OUTPUT_4WHOSAMPLED_FILE, csv4Whosampled(data), 'utf8')



  })
  .catch(function(err) {
github interactivethings / galaxy-of-covers / data / js / musixmatch.js View on Github external
.then(function(data) {
    console.log('Writing to', OUTPUT_FILE);
    genreStats(data);
    spotifyStats(data);
    rw.writeFileSync(OUTPUT_FILE, JSON.stringify(data, undefined, 2), 'utf8')
  })
  .catch(function(err) {
github interactivethings / galaxy-of-covers / data / js / spotify.js View on Github external
var id = trackDatum.spotify.id;
          if (!existingIds[id]) {
            existingIds[id] = trackDatum;
            vMemo.push(trackDatum);
          } else {
            console.log("Warning: two versions with the same spotify id. Keeping the version dated:", existingIds[id].date, "instead of the one dated:", trackDatum.date);
          }
        } else {
          vMemo.push(trackDatum);
        }
        return vMemo;
      }, []);
    });

    console.log('Writing to', OUTPUT_FILE);
    rw.writeFileSync(OUTPUT_FILE, JSON.stringify(data, undefined, 2), 'utf8')
  });
github interactivethings / galaxy-of-covers / data / js / echonest.js View on Github external
var songMM = _.first(utils.getIn(musixmatchData, ['response', 'songs']));
              if (songMM) {
                var track = _.first(utils.getIn(songMM, ['tracks']));
                var matchesMM = utils.getIn(track, ['foreign_id']).match(/^musixmatch-WW:track:(\d*)/);
                if (matchesMM) {
                  var musixmatch = matchesMM[1];
                  _.extend(echonest, {musixmatch: musixmatch});
                }
              }

              if (analysisData) {
                //_.extend(echonest, { analysis: analysisData.segments });
                var fname = ANALYSIS_OUT + '/' + version.spotify.id + '.json';
                console.log('Writing to', fname);
                rw.writeFileSync(fname, JSON.stringify(analysisData), 'utf8')
              }

              _.extend(version, { echonest: echonest });
              callback(null, version);
            })
            .catch(callback);
github interactivethings / galaxy-of-covers / data / js / whosampled.js View on Github external
q.awaitAll(function(error, samplesData) {
  if (error) {
    console.log("error: ", error);
  } else {
    rw.writeFileSync(OUTPUT_FILE, JSON.stringify(samplesData, undefined, 2), 'utf8');
  }
})
github mapbox / mapbox-gl-js / js / style-spec / minify.js View on Github external
files.forEach((file) => {
    if (file.match(/.min.json/i) !== null) return;
    rw.writeFileSync(file.replace(/.json/i, '.min.json'),
        JSON.stringify(JSON.parse(rw.readFileSync(file)), replacer, 0)
    );
});
github dataproofer / Dataproofer / src / index.js View on Github external
var outPath = program.out ? program.out : "/dev/stdout";
    
    if (program.out) resultStr = resultStr.replace(/\[\d+m/g, "");
    if (program.json === true) {
      rw.writeFileSync(outPath, JSON.stringify(results), "utf-8");
      done();
      return;
    }
    if (program.jsonPretty === true) {
      rw.writeFileSync(outPath, JSON.stringify(results, null, 2), "utf-8");
      done();
      return;
    }
    if (program.summary !== true) {
      rw.writeFileSync(outPath, resultStr, "utf-8");
      done();
      return;
    }
  } else {
    process.stderr.write(
      chalk.red("Error: Must use a supported filetype. Currently supported filetypes: " + allowFileExtensions.join(", "), "utf-8")
    );
  }
}
github interactivethings / galaxy-of-covers / data / js / request-cache.js View on Github external
.then(function(d) {
      rw.writeFileSync(fname, d, 'utf8');
      resolve(d);
    })
    .catch(function(err) {

rw

Now stdin and stdout are files.

BSD-3-Clause
Latest version published 8 years ago

Package Health Score

67 / 100
Full package analysis