file-to-tar
Create a tar archive from a single file with the Observable API
const existsSync = ;const fileToTar = ; const subscription = ; // Cancel compressionsubscription;
Installation
npm install file-to-tar
API
const fileToTar = ;
fileToTar(filePath, tarPath [, options])
filePath: string
(path of a file to compress)
tarPath: string
(path of the created archive file)
options: Object
Return: Observable
(zenparsing's implementation)
When the Observable
is subscribed, it starts to create a tar file from a given file and successively send compression progress to its Observer
.
Every progress object have two properties header
and bytes
. header
is a header of the entry, and bytes
is the total processed size of the compression.
For example you can get the progress as a percentage by (progress.bytes / progress.header.size || 0) * 100
.
;
0.0 %
0.1 %
0.3 %
0.4 %
︙
99.6 %
99.8 %
99.9 %
100.0 %
Completed
Options
You can pass options to tar-fs's pack()
method and fs.createReadStream()
. Note that:
entries
,strip
,filter
andignore
options are not supported.fs
option defaults to graceful-fs for more stability.
Additionally, you can use the following:
tarTransform
Type: Stream
A transform stream to modify the archive after compression.
For example, pass zlib.createGzip()
and you can create a gzipped tar.
const fileToTar = ;const createGzip = ; const gzipStream = ; const observable = ;
Related project
- tar-to-file – Inverse of this module. Decompress a single-file tar archive
License
ISC License © 2017 - 2018 Shinnosuke Watanabe