Commit 04230ccb by Adeel Mujahid

Merge pull request #541 from am11/master

Binary: Removes v8 version from the dir name
parents 03bd9d01 816204c9
......@@ -8,8 +8,7 @@ var fs = require('fs'),
*/
function getBinding() {
var v8 = 'v8-' + /[0-9]+\.[0-9]+/.exec(process.versions.v8)[0];
var name = process.platform + '-' + process.arch + '-' + v8;
var name = process.platform + '-' + process.arch;
var candidates = [
path.join(__dirname, '..', 'build', 'Release', 'binding.node'),
path.join(__dirname, '..', 'build', 'Debug', 'binding.node'),
......
......@@ -52,7 +52,8 @@
"nan": "^1.3.0",
"object-assign": "^1.0.0",
"replace-ext": "0.0.1",
"request": "^2.48.0"
"request": "^2.48.0",
"shelljs": "^0.3.0"
},
"devDependencies": {
"coveralls": "^2.11.1",
......
......@@ -82,8 +82,7 @@ function build(options) {
function parseArgs(args) {
var options = {
arch: process.arch,
platform: process.platform,
v8: /[0-9]+\.[0-9]+/.exec(process.versions.v8)[0]
platform: process.platform
};
options.args = args.filter(function(arg) {
......@@ -110,10 +109,7 @@ function parseArgs(args) {
*/
function testBinary(options) {
options.bin = [
options.platform + '-' + options.arch,
'-v8-' + options.v8
].join('');
options.bin = options.platform + '-' + options.arch;
if (options.force || process.env.SASS_FORCE_BUILD) {
return build(options);
......
var fs = require('fs'),
path = require('path'),
request = require('request'),
mkdirp = require('mkdirp');
mkdirp = require('mkdirp'),
exec = require('shelljs').exec;
/**
* Download file, if succeded save, if not delete
* Download file, if succeeds save, if not delete
*
* @param {String} url
* @param {String} dest
......@@ -14,17 +15,15 @@ var fs = require('fs'),
function download(url, dest, cb) {
var file = fs.createWriteStream(dest);
var env = process.env;
var options = {
proxy: env.HTTPS_PROXY || env.https_proxy || env.HTTP_PROXY || env.http_proxy
};
var options = { proxy: getProxy() };
var returnError = function(err) {
fs.unlink(dest);
cb(err);
cb(typeof err.message === 'string' ? err.message : err);
};
var req = request.get(url, options).on('response', function(response) {
if (response.statusCode < 200 || response.statusCode >= 300) {
returnError('Can not download file from ' + url);
return;
}
response.pipe(file);
......@@ -38,14 +37,40 @@ function download(url, dest, cb) {
};
/**
* Get proxy settings
*
* @api private
*/
function getProxy() {
var result;
['https-proxy', 'proxy', 'http-proxy'].map(function(config) {
var proxy = exec('npm config get ' + config, {silent: true});
var output = proxy.output.trim();
if (proxy.code === 0 && output !== 'undefined' && output !== 'null') {
result = proxy.output;
return;
}
});
if (result) {
return result;
}
var env = process.env;
return env.HTTPS_PROXY || env.https_proxy || env.HTTP_PROXY || env.http_proxy
}
/**
* Check if binaries exists
*
* @api private
*/
function exists() {
var v8 = 'v8-' + /[0-9]+\.[0-9]+/.exec(process.versions.v8)[0];
var name = process.platform + '-' + process.arch + '-' + v8;
var name = process.platform + '-' + process.arch;
fs.exists(path.join(__dirname, '..', 'vendor', name), function (exists) {
if (exists) {
......@@ -80,7 +105,7 @@ function fetch(name) {
download(url, dest, function(err) {
if (err) {
console.error(err.message);
console.error(err);
return;
}
......
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