How to use the fstream.Writer function in fstream

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 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 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'));
  })
}
github RealFaviconGenerator / grunt-real-favicon / tasks / lib / rfg_api.js View on Github external
client.post("http://realfavicongenerator.net/api/favicon", args, function(data, response) {
      if (response.statusCode !== 200) {
        grunt.warn(data);
        return;
      }

      var writeStream = fstream.Writer(dest);
      var parserStream = unzip.Parse();
      var request = http.get(data.favicon_generation_result.favicon.package_url, function(response) {
        response.pipe(parserStream).pipe(writeStream);
      });
      writeStream.on('close', function() {
        callback(data.favicon_generation_result);
      });
    });
  }
github fomantic / Fomantic-UI / node / node_modules / grunt-bower-task / node_modules / bower / lib / core / package.js View on Github external
return fs.rename(this.path, localPath, function (err) {
          if (!err) return this.cleanUpLocal();

          var writter = fstream.Writer({
            type: 'Directory',
            path: localPath
          });
          writter
            .on('error', this.emit.bind(this, 'error'))
            .on('end', rimraf.bind(this, this.path, this.cleanUpLocal.bind(this)));

          fstream.Reader(this.path)
            .on('error', this.emit.bind(this, 'error'))
            .pipe(writter);
        }.bind(this));
      }.bind(this));
github mmalecki / apm / lib / apm / install.js View on Github external
mkdirp(installedPath, function (err) {
          if (err) {
            return cb(err);
          }

          fstream.Reader(cachePath)
            .pipe(fstream.Writer(installedPath))
            .on('error', cb)
            .on('close', function () {
              link(installedPath, self.prefix, function (err) {
                cb(err, installedPath, content.version);
              });
            });
        });
      });

fstream

Advanced file system stream things

ISC
Latest version published 5 years ago

Package Health Score

52 / 100
Full package analysis

Popular fstream functions