unpack-stream
Unpack a tarball stream
Installation
npm i -S unpack-stream
Usage
'use strict'
const got = require('got')
const unpackStream = require('unpack-stream')
const tarball = 'https://registry.npmjs.org/is-negative/-/is-negative-2.1.0.tgz'
const stream = got.stream(tarball)
unpackStream.remote(stream, './tmp')
.then(index =>
Promise.all(
Object.keys(index)
.map(filename =>
index[filename].generatingIntegrity.then(integrity => ({filename, integrity})))
)
)
.then(files => console.log(files))
API
remote(stream, destination, [opts]): Promise<Index>
Unpacks a remote stream fetched via HTTP.
Arguments:
stream
- Streamdestination
- string - the directory to which the stream will be unpacked[opts.shasum]
- string - shasum to verify tarball[opts.onStart]
- Function - called on download start[opts.onProgress]
- (downloaded, size) => void - tracks the download progress[opts.generateIntegrity]
- Boolean - true
by default. If true
, generates Subresource Integrity for each unpacked file[opts.ignore]
- (filename: string) => boolean
- a function that decides whether a file should be unpacked from the tarball.
local(stream, destination, [opts]): Promise<Index>
Unpacks a stream from the local filesystem.
Arguments:
[opts.generateIntegrity]
- Boolean - true
by default. If true
, generates Subresource Integrity for each unpacked file[opts.ignore]
- (filename: string) => boolean
- a function that decides whether a file should be unpacked from the tarball.
License
MIT © Zoltan Kochan