refactor httpsGet

This commit is contained in:
Iuri Matias 2017-12-15 22:05:38 -05:00
parent bee4d0e1f2
commit 510bc2c542
2 changed files with 53 additions and 52 deletions

View File

@ -17,13 +17,7 @@ class Npm {
let self = this;
let npmRegistry = "https://registry.npmjs.org/" + packageName + "/" + version;
utils.httpsGet(npmRegistry, function (res) {
let body = '';
res.on('data', function (d) {
body += d;
});
res.on('end', function () {
utils.httpsGet(npmRegistry, function (body) {
let registryJSON = JSON.parse(body);
let tarball = registryJSON.dist.tarball;
@ -101,7 +95,6 @@ class Npm {
}
});
});
}
}

View File

@ -37,7 +37,15 @@ function httpGet(url, callback) {
}
function httpsGet(url, callback) {
return https.get(url, callback);
https.get(url, function(res) {
let body = '';
res.on('data', function (d) {
body += d;
});
res.on('end', function () {
callback(body);
});
});
}
function runCmd(cmd, options) {