3.0.0 • Published 5 years ago
zip-to-tar v3.0.0
zip-to-tar

Convert zip archives to tar.
Global
zip-to-tar could be installed globally and used as zip-to-tar or zip2tar:
npm i zip-to-tar -gUsage
Convert all zip archives to tar.gz in same directory:
zip2tar *.zipMake every program a filter
(c) Mike Gancarz: The UNIX Philosophy
Convert zip data from stdin and pipe it to stdout.
cat arc.zip | zip2tar > arc.tarLocal
zip-to-tar could be used localy. It will emit event on every file from converted archive.
Install
npm i zip-to-tar --saveAPI
zip-to-tar can work with filename and ReadableStream. When filename used zip-to-tar can emit
progress of coverting (with options: {progress: true}).
zipToTar(filename, options)
filename- string name of the fileoptions- object with properties:progress- whether emitprogressevent.
const zipToTar = require('zip-to-tar');
const fs = require('fs');
const {stdout} = process;
const onProgress = (n) => {
stdout.write(`\r${n}`);
};
const onFinish = (e) => {
stdout.write('\n');
};
const onError = ({message}) => {
console.error(message)
};
const tar = fs.createWriteStream('file.tar');
const progress = true;
zipToTar('file.zip', {progress})
.on('progress', onProgress)
.on('file', console.log)
.on('error', onError);
.getStream()
.pipe(tar)
.on('finish', onFinish);zipToTar(buffer)
buffer- Buffer withzipdata.
const zipToTar = require('zip-to-tar');
const fs = require('fs');
const {stdout} = process;
const onProgress = (n) => {
stdout.write(`\r${n}`);
};
const onFinish = (e) => {
stdout.write('\n');
};
const onError = ({message}) => {
console.error(message)
};
const zip = fs.readFileSync('file.zip');
const tar = fs.createReadStream('file.tar');
const progress = true;
zipToTar(zip, {progress})
.on('file', console.log)
.on('error', onError);
.getStream()
.pipe(tar)
.on('finish', onFinish);Related
- Jaguar - Pack and extract .tar.gz archives with emitter.
- OneZip - Pack and extract zip archives with emitter.
- tar-to-zip - Convert tar and tar.gz archives to zip.
License
MIT