How to use the graceful-fs.createWriteStream function in graceful-fs

To help you get started, we’ve selected a few graceful-fs 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 graalvm / graaljs / deps / npm / node_modules / npm-lifecycle / node_modules / node-gyp / node_modules / fstream / lib / file-writer.js View on Github external
FileWriter.prototype._create = function () {
  var self = this
  if (self._stream) return

  var so = {}
  if (self.props.flags) so.flags = self.props.flags
  so.mode = Writer.filemode
  if (self._old && self._old.blksize) so.bufferSize = self._old.blksize

  self._stream = fs.createWriteStream(self._path, so)

  self._stream.on('open', function () {
    // console.error("FW open", self._buffer, self._path)
    self.ready = true
    self._buffer.forEach(function (c) {
      if (c === EOF) self._stream.end()
      else self._stream.write(c)
    })
    self.emit('ready')
    // give this a kick just in case it needs it.
    self.emit('drain')
  })

  self._stream.on('error', function (er) { self.emit('error', er) })

  self._stream.on('drain', function () { self.emit('drain') })
github pjshumphreys / querycsv / env / c64 / build-c64.js View on Github external
/*explicitly add jmpvec, so it works with rom paging*/
        if(name === "DATA" && !append && notAddedJmpVec) {
          notAddedJmpVec = false;
          writePause(activeStream, ".export jmpvec\njmpvec: jmp $ffff\n");
        }


      }
    }
    else if(/\.export/.test(line) || /\.endproc/.test(line)) {
      //do nothing
    }
    else if (/^\.proc\s+/.test(line)) {
      name = (line.replace(/^\.proc\s+/, "")).match(/[^:]+/)[0];
      functionOutputStreams.push(fs.createWriteStream('build/s/'+name+'.s'));

      activeStream = functionOutputStreams[functionOutputStreams.length-1];

      writePause(
          activeStream,
          ".segment \"CODE\"\n"+
          ".export _"+name+"\n"+
          line.replace(name, "_"+name)+"\n"
        );

      /* add an entry for each into the mapping table */
      if(name !== "_compareCodepoints") { /* compareCodepoints is a bsearch callback that
        needs to be in the same page as the function that called bsearch. it doesn't need
        to be in the jump table */
        hashMap[name] = functionsList.length;
        functionsList.push([name, 0, 0x0001, "farcall"]);
github pjshumphreys / querycsv / env / c64 / build-c64.js View on Github external
console.log('splitUpFunctions');

  var j;
  var notAddedJmpVec = true;

  var lineReader = readline.createInterface({
    input: fs.createReadStream('build/'+filename+'.s')
  });

  var data = fs.createWriteStream('build/data.s', {
    flags: append?'a':'w'
  });

  var rodataOutputStreams = [];

  var code = fs.createWriteStream('build/'+filename+'_code.s');

  var functionOutputStreams = [];
  var activeStream = code;
  var rodataType = 0;

  lineReader.on('line', function(line) {
    var name;

    if(/^\.segment\s+"[_0-9A-Z]+"/.test(line)) {
      name = line.replace(/\.segment\s+"/, "").match(/[_0-9A-Z]+/)[0];

      if(name == "CODE") {
        rodataType = 0;

        if(functionOutputStreams.length) {
          activeStream = functionOutputStreams[functionOutputStreams.length-1];
github ShieldBattery / ShieldBattery / deps / node / deps / npm / lib / utils / error-handler.js View on Github external
function writeLogFile (cb) {
  if (writingLogFile) return cb()
  writingLogFile = true
  wroteLogFile = true

  var fs = require("graceful-fs")
    , fstr = fs.createWriteStream("npm-debug.log")
    , util = require("util")
    , os = require("os")
    , out = ""

  log.record.forEach(function (m) {
    var pref = [m.id, m.level]
    if (m.prefix) pref.push(m.prefix)
    pref = pref.join(' ')

    m.message.trim().split(/\r?\n/).map(function (line) {
      return (pref + ' ' + line).trim()
    }).forEach(function (line) {
      out += line + os.EOL
    })
  })
github MobileChromeApps / mobile-chrome-apps / node_modules / cordova / node_modules / npm / lib / utils / error-handler.js View on Github external
function writeLogFile (cb) {
  if (writingLogFile) return cb()
  writingLogFile = true
  wroteLogFile = true

  var fs = require("graceful-fs")
    , fstr = fs.createWriteStream("npm-debug.log")
    , util = require("util")
    , os = require("os")
    , out = ""

  log.record.forEach(function (m) {
    var pref = [m.id, m.level]
    if (m.prefix) pref.push(m.prefix)
    pref = pref.join(' ')

    m.message.trim().split(/\r?\n/).map(function (line) {
      return (pref + ' ' + line).trim()
    }).forEach(function (line) {
      out += line + os.EOL
    })
  })
github Caltech-IPAC / firefly / node_modules / babel-core / node_modules / regenerator / node_modules / commoner / lib / util.js View on Github external
return makePromise(function(callback) {
        var reader = fs.createReadStream(srcFile);

        function onError(err) {
            callback(err || new Error(
                "error in util.copyP(" +
                    JSON.stringify(srcFile) + ", " +
                    JSON.stringify(dstFile) + ")"
            ));
        }

        reader.on("error", onError).pipe(
            fs.createWriteStream(dstFile)
        ).on("finish", function() {
            callback(null, dstFile);
        }).on("error", onError);
    });
};
github nullivex / nodist / bin / node_modules / npm / lib / cache.js View on Github external
mkdir(path.dirname(tmp), function (er) {
      if (er) return cb(er)
      var gzip = zlib.createGzip({ level: 9 })
      var git = npm.config.get("git")
      var args = ["archive", co, "--format=tar", "--prefix=package/"]
      var out = fs.createWriteStream(tmp)
      var env = gitEnv()
      cb = once(cb)
      var cp = spawn(git, args, { env: env, cwd: p })
      cp.on("error", cb)
      cp.stderr.on("data", function(chunk) {
        log.silly(chunk.toString(), "git archive")
      })

      cp.stdout.pipe(gzip).pipe(out).on("close", function() {
        addLocalTarball(tmp, function(er, data) {
          if (data) data._resolved = resolved
          cb(er, data)
        })
      })
    })
  }
github smartcontractkit / chainlink / examples / echo_server / node_modules / fs-extra / lib / copy / ncp.js View on Github external
function onError (err) {
    if (options.stopOnError) {
      return callback(err)
    } else if (!errs && options.errs) {
      errs = fs.createWriteStream(options.errs)
    } else if (!errs) {
      errs = []
    }
    if (typeof errs.write === 'undefined') {
      errs.push(err)
    } else {
      errs.write(err.stack + '\n\n')
    }
    return doneOne()
  }
github NuSkooler / enigma-bbs / core / scanner_tossers / ftn_bso.js View on Github external
exportOpts.destAddress,
								exportOpts.nodeConfig.packetType);

							packetHeader.password = exportOpts.nodeConfig.packetPassword || '';

							//	use current message ID for filename seed
							const pktFileName = self.getOutgoingPacketFileName(
								self.exportTempDir,
								message.messageId,
								createTempPacket,
								exportOpts.fileCase
							);

							exportedFiles.push(pktFileName);

							ws = fs.createWriteStream(pktFileName);

							currPacketSize = packet.writeHeader(ws, packetHeader);

							if(remainMessageBuf) {
								currPacketSize += packet.writeMessageEntry(ws, remainMessageBuf);
								remainMessageBuf = null;
							}
						}

						callback(null);
					},
					function appendMessage(callback) {
github hexojs / hexo / lib / util / file2.js View on Github external
], function(err){
    if (err) return callback(err);

    var rs = fs.createReadStream(src),
      ws = fs.createWriteStream(dest);

    rs.pipe(ws)
      .on('error', function(err){
        if (err && !called){
          called = true;
          callback(err);
        }
      });

    ws.on('close', callback)
      .on('error', function(err){
        if (err && !called){
          called = true;
          callback(err);
        }
      });