@ndelangen/get-tarball
v3.0.9
Published
Download a tarball (optionally gzipped) to a folder & extract it in the process. Uses the wonderful & super quick tar-fs & gunzip-maybe srcraries.
Downloads
8,637,953
Readme
download-tarball
Download a tarball (optionally gzipped) to a folder & extract it in the process. Uses the wonderful & super quick tar-fs & gunzip-maybe srcraries.
Installation
This is a Node.js module available through the
npm registry. It can be installed using the
npm
or
yarn
command line tools.
npm install download-tarball --save
Usage
/* eslint-disable import/no-extraneous-dependencies */
import download from 'download-tarball';
download({
url: 'http://link-to-tarball/file.tar.gz',
dir: '/dir/where/file/will/be/downloaded'
}).then(() => {
console.log('file is now downloaded!');
}).catch(err => {
console.log('oh crap the file could not be downloaded properly');
console.log(err);
});
download({
url: 'http://link-to-tarball/file.tar.gz',
dir: '/dir/where/file/will/be/downloaded',
// custom options that will be forwarded to got.stream(..., opts) can also be set
gotOpts: {
headers: {
beep: 'boop'
}
}
}).then(() => {
console.log('file is now downloaded!');
}).catch(err => {
console.log('oh crap the file could not be downloaded properly');
console.log(err);
});
download({
// neat, tar files works as well!
url: 'http://link-to-tarball/file.tar',
dir: '/dir/where/file/will/be/downloaded'
}).then(() => {
console.log('file is now downloaded!');
}).catch(err => {
console.log('oh crap the file could not be downloaded properly');
console.log(err);
});
Tests
npm install
npm test
Dependencies
- gunzip-maybe: Transform stream that gunzips its input if it is gzipped and just echoes it if not
- pump: pipe streams together and close all of them if one of them closes
- tar-fs: filesystem bindings for tar-stream
License
MIT