download-tarball
Advanced tools
Comparing version 1.0.0 to 1.0.1
@@ -11,5 +11,5 @@ 'use strict'; | ||
var _endOfStream = require('end-of-stream'); | ||
var _pump = require('pump'); | ||
var _endOfStream2 = _interopRequireDefault(_endOfStream); | ||
var _pump2 = _interopRequireDefault(_pump); | ||
@@ -24,9 +24,8 @@ var _tarFs = require('tar-fs'); | ||
module.exports = function (_ref) { | ||
module.exports = _bluebird2.default.promisify(function (_ref, callback) { | ||
var url = _ref.url; | ||
var gotOpts = _ref.gotOpts; | ||
var dir = _ref.dir; | ||
return _bluebird2.default.promisify(function (callback) { | ||
(0, _endOfStream2.default)(_got2.default.stream(url, gotOpts).pipe((0, _gunzipMaybe2.default)()).pipe((0, _tarFs.extract)(dir)), callback); | ||
}); | ||
}; | ||
(0, _pump2.default)(_got2.default.stream(url, gotOpts), (0, _gunzipMaybe2.default)(), (0, _tarFs.extract)(dir), callback); | ||
}); |
import Promise from 'bluebird'; | ||
import got from 'got'; | ||
import eos from 'end-of-stream'; | ||
import pipe from 'pump'; | ||
import {extract} from 'tar-fs'; | ||
import gunzipMaybe from 'gunzip-maybe'; | ||
module.exports = ({url, gotOpts, dir}) => | ||
Promise.promisify(callback => { | ||
eos( | ||
got | ||
.stream(url, gotOpts) | ||
.pipe(gunzipMaybe()) | ||
.pipe(extract(dir)), | ||
callback | ||
); | ||
}); | ||
module.exports = Promise.promisify(({url, gotOpts, dir}, callback) => { | ||
pipe( | ||
got.stream(url, gotOpts), | ||
gunzipMaybe(), | ||
extract(dir), | ||
callback | ||
); | ||
}); |
{ | ||
"name": "download-tarball", | ||
"version": "1.0.0", | ||
"version": "1.0.1", | ||
"description": "Download a tarball (optionally gzipped) to a folder & extract it in the process. Uses the wonderful & super quick tar-fs & gunzip-maybe libraries.", | ||
@@ -38,7 +38,7 @@ "main": "dist/index.js", | ||
"bluebird": "^3.4.1", | ||
"end-of-stream": "^1.1.0", | ||
"got": "^6.3.0", | ||
"gunzip-maybe": "^1.3.1", | ||
"pump": "^1.0.1", | ||
"tar-fs": "^1.13.0" | ||
} | ||
} |
@@ -67,5 +67,5 @@ # download-tarball | ||
- [bluebird](https://github.com/petkaantonov/bluebird): Full featured Promises/A+ implementation with exceptionally good performance | ||
- [end-of-stream](https://github.com/mafintosh/end-of-stream): Call a callback when a readable/writable/duplex stream has completed or failed. | ||
- [got](https://github.com/sindresorhus/got): Simplified HTTP requests | ||
- [gunzip-maybe](https://github.com/mafintosh/gunzip-maybe): Transform stream that gunzips its input if it is gzipped and just echoes it if not | ||
- [pump](https://github.com/mafintosh/pump): pipe streams together and close all of them if one of them closes | ||
- [tar-fs](https://github.com/mafintosh/tar-fs): filesystem bindings for tar-stream | ||
@@ -72,0 +72,0 @@ |
@@ -31,3 +31,3 @@ import http from 'http'; | ||
yield download({ | ||
const d = download({ | ||
url, | ||
@@ -41,2 +41,6 @@ gotOpts: { | ||
}); | ||
t.truthy(d.then, 'answer is promise'); | ||
yield d; | ||
const actualContent = yield fs.readFile(join(tmpDir, 'test.txt'), 'utf8'); | ||
@@ -43,0 +47,0 @@ const expectedContent = 'this is the test file'; |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
9457
107
+ Addedpump@^1.0.1
- Removedend-of-stream@^1.1.0