Convert tar and tar.gz archives to zip.
Global
tar-to-zip
could be installed globally and used as tar-to-zip
or tar2zip
:
npm i tar-to-zip -g
Usage
Convert all tar.gz
archives to zip
in same directory:
tar2zip *.tar.gz
Make every program a filter
(c) Mike Gancarz: The UNIX Philosophy
Convert tar
data from stdin
and pipe it to stdout
.
cat arc.tar | tar2zip > arc.zip
Local
tar-to-zip
could be used localy. It will emit event on every file from converted archive.
Install
npm i tar-to-zip --save
API
tar-to-zip
can work with filename
and ReadableStream
. When filename
used tar-to-zip
can emit
progress of coverting (with options
: {progress: true}
).
tar-to-zip
can transform the files as they are being processed using options
: map
and filter
.
tarToZip(filename, {progress})
filename
- string name of the fileoptions
- object with properties:progress
- whether emitprogress
event.
const tarToZip = ;const fs = ;const stdout = process; const onProgress = { stdout;}; const onFinish = { stdout;}; const onError = { console;}; const zip = fs;const progress = true; ;
tarToZip(stream)
stream
- ReadableStream withtar
data.
const tarToZip = ;const fs = ;const stdout = process; const onProgress = { stdout;};const onFinish = { stdout;}; const onError = { console}; const tar = fs;const zip = fs;const progress = true; ;
tarToZip(stream, {filter, map})
options
- ReadableStream withtar
data.filter
- function to filter out files. Returnfalse
to exclude a file.map
- function to transform file name/type.
const tarToZip = ;const fs = ;const stdout = process;const onProgress = { stdout;}; const onFinish = { stdout;}; const onError = { console;}; const zip = fs;const progress = false; // exclude all but example.txtconst filter = { return name === 'example.txt';}; // replace all .txt extensions with .docconst map = { return name: name ;}; ;
Related
- Jag - Pack files and folders with tar and gzip.
- Jaguar - Pack and extract .tar.gz archives with emitter.
- OneZip - Pack and extract zip archives with emitter.
- zip-to-tar - Convert zip archives to tar.
License
MIT