How to use unzip - 10 common examples

To help you get started, we’ve selected a few unzip 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 exceljs / exceljs / test / testZipRead.js View on Github external
var fs = require('fs');
var unzip = require('unzip');
var Sax = require('sax');

var filename = process.argv[2];

var zipEntries = {};
var zipStream = unzip.Parse();
zipStream.on('entry',function (entry) {
  console.log(entry.path)
  // zipEntries[entry.path] = entry;
  entry.autodrain();
});
zipStream.on('close', function () {
  console.log('zip close')
});

var readStream = fs.createReadStream(filename);
readStream.pipe(zipStream);
github exceljs / exceljs / test / testSax.js View on Github external
}

var count = 0;
var e = new events.EventEmitter();
e.on('row', function(row) {
    count++;

    if (count % 1000 === 0) {
        process.stdout.write('Count:' + count + '\u001b[0G'); // "\033[0G"
    }
});
e.on('finished', function() {
    console.log('Finished worksheet: ' + count);
});

var zip = unzip.Parse();
zip.on('entry',function (entry) {
    if (entry.path.match(/xl\/worksheets\/sheet\d+[.]xml/)) {
        parseSheet(entry,e);
    }
});

function parseSheet(entry, emitter) {
    var parser = Sax.createStream(true, {});
    var row = null;
    var cell = null;
    var current = null;
    parser.on('opentag', function(node) {
        switch(node.name) {
            case 'row':
                var r = parseInt(node.attributes.r);
                row = new Row(r);
github processing / p5.js-editor / gulpfile.js View on Github external
gulp.task('getOfflineReference', function(){
// get latest .zip data from p5js website and unzip it.
request('http://p5js.org/offline-reference/p5-reference.zip')
  // .pipe(fs.createWriteStream('./public/mode_assets/p5/p5-reference.zip'))
  .pipe(unzip.Extract({ path: './public/mode_assets/p5/p5-reference' }))
  .on('close', function () {
    console.log('Offline Reference Retrieved!');
  });


})
github vellengs / typerx / packages / server / dist / scripts / apigen.js View on Github external
response.data.pipe(fs.createWriteStream(local)).on('finish', (done) => {
                fs.createReadStream(local).pipe(unzip.Extract({ path: 'decompress' })).on('close', (done) => __awaiter(this, void 0, void 0, function* () {
                    // await sleep(2000);
                    console.log('extracted ...');
                    fs.unlinkSync(local);
                    console.log('deleted zip file ...');
                    yield removeFolder(generatedFolder);
                    console.log('removed generated ...');
                    // await sleep(1000);
                    fs.renameSync(templateFolder, generatedFolder);
                    console.log('copy generated ...');
                    yield removeFolder(decompress);
                    console.log('done ...');
                }));
            });
        }
github vellengs / typerx / packages / server / src / scripts / apigen.ts View on Github external
response.data.pipe(fs.createWriteStream(local)).on('finish', (done: any) => {
            fs.createReadStream(local).pipe(unzip.Extract({ path: 'decompress' })).on('close',
                async (done: any) => {
                    // await sleep(2000);
                    console.log('extracted ...');
                    fs.unlinkSync(local);
                    console.log('deleted zip file ...');
                    await removeFolder(generatedFolder);
                    console.log('removed generated ...');
                    // await sleep(1000);
                    fs.renameSync(templateFolder, generatedFolder);
                    console.log('copy generated ...');
                    await removeFolder(decompress);
                    console.log('done ...');
                });
        });
    }
github coveooss / vsforce / src / utils / utils.ts View on Github external
return new Promise((resolve, reject) => {
    let zipstream = new stream.PassThrough();
    zipstream.end(new Buffer(content, 'base64'));
    zipstream.pipe(unzip.Parse())
      .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 pathephone / pathephone-desktop / build / ipfs-download.js View on Github external
return new Promise((resolve, reject) => {
    console.log('unziping', file, 'to', path)
    fs.createReadStream(file).pipe(uz.Extract({ path })).on('close', () => {
      console.log('unziped!')
      resolve()
    })
  })
}
github yorkie / tensorflow-nodejs / scripts / download.js View on Github external
https.get(PROTOBUF_URL, (res) => {
  if (res.statusCode !== 200) {
    throw new Error(PROTOBUF_URL + ' ' + res.statusMessage);
  } else {
    console.log('Done,', PROTOBUF_URL + ' is finished downloaded.');
  }
  res.pipe(unzip.Extract({
    path: './protobuf'
  }));
});
github brainfoolong / rcon-web-admin / src / widget.js View on Github external
fs.writeFile(repoDir + "/master.zip", contents, {"mode": 0o777}, function () {
                fs.createReadStream(repoDir + "/master.zip").pipe(unzip.Parse()).on('entry', function (entry) {
                    var fileName = entry.path.split("/").slice(1).join("/");
                    if (!fileName.length) return;
                    var path = repoDir + "/" + fileName;
                    if (entry.type == "Directory") {
                        fs.mkdirSync(path, 0o777);
                        entry.autodrain();
                    } else {
                        entry.pipe(fs.createWriteStream(path));
                    }
                }).on("close", function () {
                    fs.unlinkSync(repoDir + "/master.zip");
                    callback(true);
                });
            });
        });
github BlinkTagInc / node-gtfs / scripts / download.js View on Github external
function processFile(e, response, body){
        if(response && response.statusCode != 200){ cb(new Error('Couldn\'t download files')); }
        console.log(agency_key + ': Download successful');
  	
        fs.createReadStream(downloadDir + '/latest.zip')
          .pipe(unzip.Extract({ path: downloadDir }).on('close', cb))
          .on('error', handleError);
      }
    }

unzip

Unzip cross-platform streaming API compatible with fstream and fs.ReadStream

MIT
Latest version published 10 years ago

Package Health Score

48 / 100
Full package analysis

Popular unzip functions