refactor utils http get

This commit is contained in:
Iuri Matias 2017-12-15 22:15:24 -05:00
parent 301ba94ef6
commit e093ff5b30
2 changed files with 7 additions and 41 deletions

View File

@ -32,8 +32,8 @@ function checkIsAvailable(url, callback) {
});
}
function httpGet(url, callback) {
http.get(url, function(res) {
function httpGetRequest(httpObj, url, callback) {
httpObj.get(url, function(res) {
let body = '';
res.on('data', function (d) {
body += d;
@ -47,19 +47,12 @@ function httpGet(url, callback) {
});
}
function httpGet(url, callback) {
httpGetRequest(http, url, callback);
}
function httpsGet(url, callback) {
https.get(url, function(res) {
let body = '';
res.on('data', function (d) {
body += d;
});
res.on('end', function () {
callback(null, body);
});
res.on('error', function (err) {
callback(err);
});
});
httpGetRequest(https, url, callback);
}
function runCmd(cmd, options) {

View File

@ -1,27 +0,0 @@
0 info it worked if it ends with ok
1 verbose cli [ '/Users/iurimatias/.nvm/versions/node/v6.9.5/bin/node',
1 verbose cli '/Users/iurimatias/.nvm/versions/node/v6.9.5/bin/npm',
1 verbose cli 'run',
1 verbose cli 'fulltest' ]
2 info using npm@3.10.10
3 info using node@v6.9.5
4 verbose stack Error: missing script: fulltest
4 verbose stack at run (/Users/iurimatias/.nvm/versions/node/v6.9.5/lib/node_modules/npm/lib/run-script.js:151:19)
4 verbose stack at /Users/iurimatias/.nvm/versions/node/v6.9.5/lib/node_modules/npm/lib/run-script.js:61:5
4 verbose stack at /Users/iurimatias/.nvm/versions/node/v6.9.5/lib/node_modules/npm/node_modules/read-package-json/read-json.js:356:5
4 verbose stack at checkBinReferences_ (/Users/iurimatias/.nvm/versions/node/v6.9.5/lib/node_modules/npm/node_modules/read-package-json/read-json.js:320:45)
4 verbose stack at final (/Users/iurimatias/.nvm/versions/node/v6.9.5/lib/node_modules/npm/node_modules/read-package-json/read-json.js:354:3)
4 verbose stack at then (/Users/iurimatias/.nvm/versions/node/v6.9.5/lib/node_modules/npm/node_modules/read-package-json/read-json.js:124:5)
4 verbose stack at /Users/iurimatias/.nvm/versions/node/v6.9.5/lib/node_modules/npm/node_modules/read-package-json/read-json.js:243:12
4 verbose stack at /Users/iurimatias/.nvm/versions/node/v6.9.5/lib/node_modules/npm/node_modules/graceful-fs/graceful-fs.js:78:16
4 verbose stack at tryToString (fs.js:455:3)
4 verbose stack at FSReqWrap.readFileAfterClose [as oncomplete] (fs.js:442:12)
5 verbose cwd /Users/iurimatias/Projects/embark-framework/test_app
6 error Darwin 16.7.0
7 error argv "/Users/iurimatias/.nvm/versions/node/v6.9.5/bin/node" "/Users/iurimatias/.nvm/versions/node/v6.9.5/bin/npm" "run" "fulltest"
8 error node v6.9.5
9 error npm v3.10.10
10 error missing script: fulltest
11 error If you need help, you may report this error at:
11 error <https://github.com/npm/npm/issues>
12 verbose exit [ 1, true ]