Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

download-tarball

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

download-tarball - npm Package Compare versions

Comparing version 1.0.1 to 1.0.2

15

dist/index.js

@@ -21,4 +21,17 @@ 'use strict';

var _httpHttpsAgent = require('http-https-agent');
var _httpHttpsAgent2 = _interopRequireDefault(_httpHttpsAgent);
var _objectAssign = require('object-assign');
var _objectAssign2 = _interopRequireDefault(_objectAssign);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
var getAgent = (0, _httpHttpsAgent2.default)({
keepAlive: true,
maxSockets: 20
});
module.exports = _bluebird2.default.promisify(function (_ref, callback) {

@@ -29,3 +42,3 @@ var url = _ref.url;

(0, _pump2.default)(_got2.default.stream(url, gotOpts), (0, _gunzipMaybe2.default)(), (0, _tarFs.extract)(dir), callback);
(0, _pump2.default)(_got2.default.stream(url, (0, _objectAssign2.default)({ agent: getAgent(url) }, gotOpts)), (0, _gunzipMaybe2.default)(), (0, _tarFs.extract)(dir), callback);
});

@@ -0,1 +1,3 @@

/* eslint-disable import/no-extraneous-dependencies */
import download from 'download-tarball';

@@ -2,0 +4,0 @@

@@ -6,6 +6,13 @@ import Promise from 'bluebird';

import gunzipMaybe from 'gunzip-maybe';
import httpHttpsAgent from 'http-https-agent';
import assign from 'object-assign';
const getAgent = httpHttpsAgent({
keepAlive: true,
maxSockets: 20
});
module.exports = Promise.promisify(({url, gotOpts, dir}, callback) => {
pipe(
got.stream(url, gotOpts),
got.stream(url, assign({agent: getAgent(url)}, gotOpts)),
gunzipMaybe(),

@@ -12,0 +19,0 @@ extract(dir),

16

package.json
{
"name": "download-tarball",
"version": "1.0.1",
"version": "1.0.2",
"description": "Download a tarball (optionally gzipped) to a folder & extract it in the process. Uses the wonderful & super quick tar-fs & gunzip-maybe libraries.",
"main": "dist/index.js",
"scripts": {
"test": "babel-tape-runner test.js && semistandard | snazzy",
"test": "xo && babel-tape-runner test.js",
"build": "rm -rf dist && mkdir -p dist && babel lib --out-dir dist",

@@ -28,9 +28,9 @@ "watch": "rm -rf dist && mkdir -p dist && babel -w lib --out-dir dist",

"babel-tape-runner": "^2.0.1",
"http-test-server": "^1.0.0",
"package-json-to-readme": "^1.5.1",
"semistandard": "^8.0.0",
"snazzy": "^4.0.0",
"tapava": "^2.2.0",
"tar-stream": "^1.5.2",
"then-fs": "^2.0.0",
"tmp": "0.0.28"
"tmp": "0.0.28",
"xo": "^0.16.0"
},

@@ -41,5 +41,11 @@ "dependencies": {

"gunzip-maybe": "^1.3.1",
"http-https-agent": "^1.0.2",
"object-assign": "^4.1.0",
"pump": "^1.0.1",
"tar-fs": "^1.13.0"
},
"xo": {
"esnext": true,
"space": true
}
}

@@ -16,2 +16,4 @@ # download-tarball

```js
/* eslint-disable import/no-extraneous-dependencies */
import download from 'download-tarball';

@@ -70,2 +72,4 @@

- [gunzip-maybe](https://github.com/mafintosh/gunzip-maybe): Transform stream that gunzips its input if it is gzipped and just echoes it if not
- [http-https-agent](https://github.com/kesla/http-https-agent): Get either a HTTP or HTTPS agent depending on protocol
- [object-assign](https://github.com/sindresorhus/object-assign): ES2015 Object.assign() ponyfill
- [pump](https://github.com/mafintosh/pump): pipe streams together and close all of them if one of them closes

@@ -80,5 +84,4 @@ - [tar-fs](https://github.com/mafintosh/tar-fs): filesystem bindings for tar-stream

- [babel-tape-runner](https://github.com/wavded/babel-tape-runner): Babel + Tape for running your ES Next tests
- [http-test-server](https://github.com/kesla/test-http-server): Create a simple http server for tests
- [package-json-to-readme](https://github.com/zeke/package-json-to-readme): Generate a README.md from package.json contents
- [semistandard](https://github.com/Flet/semistandard): All the goodness of `feross/standard` with semicolons sprinkled on top.
- [snazzy](https://github.com/feross/snazzy): Format JavaScript Standard Style as Stylish (i.e. snazzy) output
- [tapava](https://github.com/kesla/tapava): the syntax of ava, run through tape

@@ -88,2 +91,3 @@ - [tar-stream](https://github.com/mafintosh/tar-stream): tar-stream is a streaming tar parser and generator and nothing else. It is streams2 and operates purely using streams which means you can easily extract/parse tarballs without ever hitting the file system.

- [tmp](https://github.com/raszi/node-tmp): Temporary file and directory creator
- [xo](https://github.com/sindresorhus/xo): JavaScript happiness style linter ❤️

@@ -90,0 +94,0 @@

@@ -1,33 +0,26 @@

import http from 'http';
import Promise from 'bluebird';
import {join} from 'path';
import {pack} from 'tar-stream';
import tmp from 'tmp';
import test from 'tapava';
import download from './lib';
import fs from 'then-fs';
import {join} from 'path';
import setupServer from 'http-test-server';
import download from './lib';
test('downloadTarball()', function * (t) {
const {url, close} = yield new Promise(resolve => {
const server = http.createServer((req, res) => {
t.match(req.headers, {custom: 'beep-boop'});
const {baseUrl, shutdown} = yield setupServer((req, res) => {
t.match(req.headers, {custom: 'beep-boop'});
// only testing tar here since we're using gunzip-maybe that handles gzip
const packStream = pack();
packStream.entry({name: 'test.txt'}, 'this is the test file');
packStream.finalize();
packStream.pipe(res);
}).listen(0, () => {
resolve({
url: `http://localhost:${server.address().port}/`,
close: () => new Promise(resolve => {
server.close(() => resolve(null));
})
});
});
// only testing tar here since we're using gunzip-maybe that handles gzip
const packStream = pack();
packStream.entry({name: 'test.txt'}, 'this is the test file');
packStream.finalize();
packStream.pipe(res);
});
const {name: tmpDir} = tmp.dirSync();
const d = download({
url,
url: baseUrl,
gotOpts: {

@@ -47,3 +40,3 @@ headers: {

t.is(actualContent, expectedContent);
yield close();
yield shutdown();
});
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc