refactor httpsGet
This commit is contained in:
parent
bee4d0e1f2
commit
510bc2c542
|
@ -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 {
|
|||
}
|
||||
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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) {
|
||||
|
|
Loading…
Reference in New Issue