Skip to content
This repository was archived by the owner on Apr 28, 2025. It is now read-only.

Commit 861da47

Browse files
author
Jan Krems
committed
refactor: drop download, runs on node 6
Fixes #19
1 parent af2e601 commit 861da47

File tree

2 files changed

+10
-9
lines changed

2 files changed

+10
-9
lines changed

lib/download.js

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,10 @@
3030
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
3131
*/
3232
'use strict';
33-
var download = require('download');
33+
var fs = require('fs');
34+
var path = require('path');
35+
36+
var request = require('request');
3437

3538
function parseHashes(rawHash) {
3639
function parse(result, hash) {
@@ -46,18 +49,18 @@ function parseHashes(rawHash) {
4649

4750
function downloadWithMD5(url, destinationDir, fileName, callback) {
4851
var hash = null;
49-
var fileOptions = {
50-
url: url,
51-
name: fileName
52-
};
53-
var stream = download(fileOptions, destinationDir);
52+
var stream = request(url, { gzip: true });
53+
var fileStream = fs.createWriteStream(path.join(destinationDir, fileName));
54+
stream.pipe(fileStream);
5455
stream.on('response', function onResponse(response) {
5556
var rawHash;
5657
rawHash = response.headers['x-goog-hash'];
5758
hash = parseHashes(rawHash).md5;
5859
});
5960
stream.on('error', callback);
60-
stream.on('close', function returnHash() {
61+
fileStream.on('error', callback);
62+
63+
fileStream.on('close', function returnHash() {
6164
callback(null, hash);
6265
});
6366
}

package.json

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,6 @@
2727
"dependencies": {
2828
"adm-zip": "~0.4.4",
2929
"async": "~0.2.10",
30-
"download": "~0.1.11",
31-
"follow-redirects": "0.0.3",
3230
"fs.extra": "^1.2.1",
3331
"lodash": "^4.6.1",
3432
"mkdirp": "~0.3.5",

0 commit comments

Comments
 (0)