@ndelangen/get-tarball
TypeScript icon, indicating that this package has built-in type declarations

3.0.9 • Public • Published

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

Readme

Keywords

none

Package Sidebar

Install

npm i @ndelangen/get-tarball

Weekly Downloads

1,707,928

Version

3.0.9

License

MIT

Unpacked Size

586 kB

Total Files

8

Last publish

Collaborators

  • ndelangen