mirror of https://github.com/embarklabs/embark.git
downloadFile should callback w/ err msg if response code is not 200
This commit is contained in:
parent
cbd208cae1
commit
ed48599aa9
|
@ -160,6 +160,9 @@ function downloadFile(url, dest, cb) {
|
||||||
const o_fs = require('fs-extra');
|
const o_fs = require('fs-extra');
|
||||||
var file = o_fs.createWriteStream(dest);
|
var file = o_fs.createWriteStream(dest);
|
||||||
(url.substring(0, 5) === 'https' ? https : http).get(url, function (response) {
|
(url.substring(0, 5) === 'https' ? https : http).get(url, function (response) {
|
||||||
|
if (response.statusCode !== 200) {
|
||||||
|
if (cb) cb(`Download failed, response code ${response.statusCode}`);
|
||||||
|
}
|
||||||
response.pipe(file);
|
response.pipe(file);
|
||||||
file.on('finish', function () {
|
file.on('finish', function () {
|
||||||
file.close(cb);
|
file.close(cb);
|
||||||
|
|
Loading…
Reference in New Issue