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
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',
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({
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
Dev Dependencies
- @types/gunzip-maybe: TypeScript definitions for gunzip-maybe
- @types/jest: TypeScript definitions for Jest
- @types/node: TypeScript definitions for Node.js
- @types/pump: TypeScript definitions for pump
- @types/tar-fs: TypeScript definitions for tar-fs
- http-test-server: Create a simple http server for tests
- jest: Delightful JavaScript Testing.
- package-json-to-readme: Generate a README.md from package.json contents
- tar-stream: tar-stream is a streaming tar parser and generator and nothing else. It operates purely using streams which means you can easily extract/parse tarballs without ever hitting the file system.
- tmp: Temporary file and directory creator
- ts-jest: A Jest transformer with source map support that lets you use Jest to test projects written in TypeScript
- tsup: Bundle your TypeScript library with no config, powered by esbuild
- got: Human-friendly and powerful HTTP request library for Node.js
- typescript: TypeScript is a language for application scale JavaScript development
License
MIT