Commit dfc026ba by Adeel Mujahid

Merge pull request #667 from am11/master

Code: Minor fixes.
parents 5bff1c73 63331e07
...@@ -9,10 +9,10 @@ var semver = require('semver'), ...@@ -9,10 +9,10 @@ var semver = require('semver'),
function getRuntimeName() { function getRuntimeName() {
var runtime = process.execPath var runtime = process.execPath
.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 ||
} env.HTTPS_PROXY ||
env.https_proxy ||
env.HTTP_PROXY ||
env.http_proxy;
options.proxy = proxyUrl;
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