Commit 63331e07 by Adeel

Code: Minor fixes.

parent 5bff1c73
...@@ -12,7 +12,7 @@ function getRuntimeName() { ...@@ -12,7 +12,7 @@ function getRuntimeName() {
.split(/[\\/]+/).pop() .split(/[\\/]+/).pop()
.split('.').shift(); .split('.').shift();
return runtime === 'node' || runtime === 'nodejs' ? 'node' : runtime; return runtime === 'nodejs' ? 'node' : runtime;
} }
/** /**
......
...@@ -22,11 +22,13 @@ function download(url, dest, cb) { ...@@ -22,11 +22,13 @@ function download(url, dest, cb) {
var returnError = function(err) { var returnError = function(err) {
cb(typeof err.message === 'string' ? err.message : err); cb(typeof err.message === 'string' ? err.message : err);
}; };
request.get(url, options).on('response', function(response) { request.get(url, options).on('response', function(response) {
if (response.statusCode < 200 || response.statusCode >= 300) { if (response.statusCode < 200 || response.statusCode >= 300) {
returnError('Can not download file from ' + url); returnError('Can not download file from ' + url);
return; return;
} }
response.pipe(fs.createWriteStream(dest)); response.pipe(fs.createWriteStream(dest));
}).on('error', returnError); }).on('error', returnError);
}); });
...@@ -45,21 +47,19 @@ function applyProxy(options, cb) { ...@@ -45,21 +47,19 @@ function applyProxy(options, cb) {
var proxyUrl; var proxyUrl;
if (!er) { if (!er) {
['https-proxy', 'proxy', 'http-proxy'].some(function(setting) { proxyUrl = conf.get('https-proxy') ||
var npmProxyUrl = conf.get(setting); conf.get('proxy') ||
if (npmProxyUrl) { conf.get('http-proxy');
proxyUrl = npmProxyUrl;
return true;
}
});
} }
if (!proxyUrl) {
var env = process.env; var env = process.env;
proxyUrl = env.HTTPS_PROXY || env.https_proxy || env.HTTP_PROXY || env.http_proxy;
}
options.proxy = proxyUrl; options.proxy = proxyUrl ||
env.HTTPS_PROXY ||
env.https_proxy ||
env.HTTP_PROXY ||
env.http_proxy;
cb(options); cb(options);
}); });
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment