How to use fstream - 10 common examples

To help you get started, we’ve selected a few fstream 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 leungwensen / svg-icon / bin / export-svg-icons.js View on Github external
.on('finish', () => {
          console.log(`${output} written.`)
          if (commander.unzip) {
            const unzipOuput = output.replace(/\.zip\s*$/, '');
            // make sure the extracting path exist and empty
            shelljs.rm('-rf', unzipOuput);
            shelljs.mkdir('-p', unzipOuput);
            const readStream = fs.createReadStream(output);
            const writeStream = fstream.Writer(unzipOuput);
            readStream
              .pipe(unzip.Parse())
              .pipe(writeStream);
          }
        });
    });
github alanhoff / node-tar.gz / index.js View on Github external
TarGz.prototype.createReadStream = function(directory) {

  // Create all needed streams
  var stream1 = fstream.Reader(directory);
  var stream2 = tar.Pack(this._options.tar);
  var stream3 = zlib.createGzip(this._options.zlib);

  // Bubble erros
  this._bubble(stream3, stream2, stream1);

  return stream1.pipe(stream2).pipe(stream3);
};
github oortcloud / meteorite / spec / acceptance / helpers.js View on Github external
var invokeInNew = function(command, directory, options, fn) {
  
  // copy directory into newApps
  var from = path.resolve(path.join('spec', 'support', 'apps', directory));
  var to = path.resolve(path.join('spec', 'support', 'apps', 'new_apps', directory));
  
  wrench.mkdirSyncRecursive(to);
  var reader = fstream.Reader(from);
  var writer = fstream.Writer(to);
  
  writer.on('close', function() {
    invoke(command, path.join('new_apps', directory), options, fn);
  });
  
  reader.pipe(writer);
}
github oortcloud / meteorite / spec / acceptance / helpers.js View on Github external
var invokeInNew = function(command, directory, options, fn) {
  
  // copy directory into newApps
  var from = path.resolve(path.join('spec', 'support', 'apps', directory));
  var to = path.resolve(path.join('spec', 'support', 'apps', 'new_apps', directory));
  
  wrench.mkdirSyncRecursive(to);
  var reader = fstream.Reader(from);
  var writer = fstream.Writer(to);
  
  writer.on('close', function() {
    invoke(command, path.join('new_apps', directory), options, fn);
  });
  
  reader.pipe(writer);
}
github manrueda / repo-copy / src / repo-copy.js View on Github external
return new Promise((resolve, reject) => {
      var dest = fstream.Writer({ path: destination });
      dest.on("close", function(ex) {
        resolve(tempPath);
      });
      fstream.Reader({ path: tempPath, type: 'Directory' }) /* Read the source directory */
      .pipe(tar.Pack()) /* Convert the directory to a .tar file */
      .pipe(zlib.Gzip()) /* Compress the .tar file */
      .pipe(dest); /* Give the output file name */
    });
  },
github coveooss / vsforce / src / utils / utils.ts View on Github external
.on('entry', (entry: any) => {
        entry.path = entry.path.replace('unpackaged/', '');
        entry.pipe(fstream.Writer({
          type: entry.type,
          path: target + entry.path
        }))
          .on('end', () => { resolve(true); }) // Finished
          .on('error', (err: any) => { reject(err); });
      });
  });
github swarajban / npm-cache / cacheDependencyManagers / cacheDependencyManager.js View on Github external
function onFinally() {
    if (fs.existsSync(fileBackupDirectory)) {
      fs.removeSync(fileBackupDirectory);
    }

    if (fs.existsSync(tmpName)) {
      fs.removeSync(tmpName);
    }
  }

  var installedDirectoryStream = fstream.Reader({path: installedDirectory}).on('error', onError);
  // TODO: speed this up
  if (this.config.noArchive) {
    installedDirectoryStream
      .on('end', onEnd)
      .pipe(fstream.Writer({path: tmpName, type: 'Directory'}));

  } else {
    tar.pack(installedDirectory)
      .pipe(zlib.createGzip())
      .pipe(fs.createWriteStream(tmpName))
      .on('error', onError)
      .on('finish', onEnd);
  }
};
github Level / leveldown / test / functional / tarcommon.js View on Github external
module.exports.fstreamWrite = function (callback) {
  fstream.Reader(datadir)
    .pipe(db.writeStream({ fstreamRoot: path.resolve(__dirname) })
      .on('close', function () {
        console.log('Piped data to database...')
        callback()
      }))
      .on('error', callback)
}
github PokemonGoers / PredictPokemon-2 / unzip.js View on Github external
function unzip_file(zip, path, file, check, size, i) {
        var readStream = fs.createReadStream(__dirname+zip[i]);
        var writeStream = fstream.Writer(__dirname+path[i]);
        readStream.pipe(unzip.Parse()).pipe(writeStream);
        writeStream.on('close', function () {
            check(__dirname+file[i]);
            if ((i + 1) < size)
                unzip_file(zip, path, file, check, size, (i + 1));
            //else do_stuff();
        });
        console.log("File " + file[i] + " extracted to " + path[i]);
    }
github silklabs / silk / node_modules / fsevents / node_modules / tar-pack / index.js View on Github external
})
        .on('close', function () {
          tarball.emit('close')
        })
      return
    }
    if (type === 'naked-file' && defaultName) {
      var jsOpts = { path: path.resolve(target, defaultName) }

      if (!win32 && typeof uid === 'number' && typeof gid === 'number') {
        jsOpts.uid = uid
        jsOpts.gid = gid
      }

      strm
        .pipe(fstream.Writer(jsOpts))
        .on('error', function (er) {
          if (er) debug('copy error')
          tarball.emit('error', er)
        })
        .on('close', function () {
          tarball.emit('close')
        })
      return
    }

    return cb(new Error('Unrecognised package type'));
  })
}

fstream

Advanced file system stream things

ISC
Latest version published 5 years ago

Package Health Score

52 / 100
Full package analysis

Popular fstream functions