Skip to content
This repository has been archived by the owner on Jul 24, 2024. It is now read-only.

Fix binary being saved with encoding #2276

Merged
merged 1 commit into from
Mar 11, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions scripts/install.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ function download(url, dest, cb) {
console.log('Downloading binary from', url);

try {
request(url, downloadOptions(), function(err, response) {
request(url, downloadOptions(), function(err, response, buffer) {
if (err) {
reportError(err);
} else if (!successful(response)) {
Expand All @@ -60,10 +60,12 @@ function download(url, dest, cb) {
console.log('Download complete');

if (successful(response)) {
response.pipe(fs.createWriteStream(dest));
fs.createWriteStream(dest)
.on('error', cb)
.end(buffer, cb);
} else {
cb();
}

cb();
}
})
.on('response', function(response) {
Expand Down
3 changes: 2 additions & 1 deletion scripts/util/downloadoptions.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ module.exports = function() {
timeout: 60000,
headers: {
'User-Agent': userAgent(),
}
},
encoding: null,
};

var proxyConfig = proxy();
Expand Down
9 changes: 6 additions & 3 deletions test/downloadoptions.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ describe('util', function() {
timeout: 60000,
headers: {
'User-Agent': ua(),
}
},
encoding: null,
};

assert.deepEqual(opts(), expected);
Expand All @@ -37,7 +38,8 @@ describe('util', function() {
timeout: 60000,
headers: {
'User-Agent': ua(),
}
},
encoding: null,
};

assert.deepEqual(opts(), expected);
Expand All @@ -61,7 +63,8 @@ describe('util', function() {
timeout: 60000,
headers: {
'User-Agent': ua(),
}
},
encoding: null,
};

assert.deepEqual(opts(), expected);
Expand Down