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'), ...@@ -8,8 +8,7 @@ var fs = require('fs'),
*/ */
function getBinding() { function getBinding() {
var v8 = 'v8-' + /[0-9]+\.[0-9]+/.exec(process.versions.v8)[0]; var name = process.platform + '-' + process.arch;
var name = process.platform + '-' + process.arch + '-' + v8;
var candidates = [ var candidates = [
path.join(__dirname, '..', 'build', 'Release', 'binding.node'), path.join(__dirname, '..', 'build', 'Release', 'binding.node'),
path.join(__dirname, '..', 'build', 'Debug', 'binding.node'), path.join(__dirname, '..', 'build', 'Debug', 'binding.node'),
......
...@@ -52,7 +52,8 @@ ...@@ -52,7 +52,8 @@
"nan": "^1.3.0", "nan": "^1.3.0",
"object-assign": "^1.0.0", "object-assign": "^1.0.0",
"replace-ext": "0.0.1", "replace-ext": "0.0.1",
"request": "^2.48.0" "request": "^2.48.0",
"shelljs": "^0.3.0"
}, },
"devDependencies": { "devDependencies": {
"coveralls": "^2.11.1", "coveralls": "^2.11.1",
......
...@@ -82,8 +82,7 @@ function build(options) { ...@@ -82,8 +82,7 @@ function build(options) {
function parseArgs(args) { function parseArgs(args) {
var options = { var options = {
arch: process.arch, arch: process.arch,
platform: process.platform, platform: process.platform
v8: /[0-9]+\.[0-9]+/.exec(process.versions.v8)[0]
}; };
options.args = args.filter(function(arg) { options.args = args.filter(function(arg) {
...@@ -110,10 +109,7 @@ function parseArgs(args) { ...@@ -110,10 +109,7 @@ function parseArgs(args) {
*/ */
function testBinary(options) { function testBinary(options) {
options.bin = [ options.bin = options.platform + '-' + options.arch;
options.platform + '-' + options.arch,
'-v8-' + options.v8
].join('');
if (options.force || process.env.SASS_FORCE_BUILD) { if (options.force || process.env.SASS_FORCE_BUILD) {
return build(options); return build(options);
......
var fs = require('fs'), var fs = require('fs'),
path = require('path'), path = require('path'),
request = require('request'), 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} url
* @param {String} dest * @param {String} dest
...@@ -14,17 +15,15 @@ var fs = require('fs'), ...@@ -14,17 +15,15 @@ var fs = require('fs'),
function download(url, dest, cb) { function download(url, dest, cb) {
var file = fs.createWriteStream(dest); var file = fs.createWriteStream(dest);
var env = process.env; var options = { proxy: getProxy() };
var options = {
proxy: env.HTTPS_PROXY || env.https_proxy || env.HTTP_PROXY || env.http_proxy
};
var returnError = function(err) { var returnError = function(err) {
fs.unlink(dest); fs.unlink(dest);
cb(err); cb(typeof err.message === 'string' ? err.message : err);
}; };
var req = request.get(url, options).on('response', function(response) { var req = 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;
} }
response.pipe(file); response.pipe(file);
...@@ -38,14 +37,40 @@ function download(url, dest, cb) { ...@@ -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 * Check if binaries exists
* *
* @api private * @api private
*/ */
function exists() { function exists() {
var v8 = 'v8-' + /[0-9]+\.[0-9]+/.exec(process.versions.v8)[0]; var name = process.platform + '-' + process.arch;
var name = process.platform + '-' + process.arch + '-' + v8;
fs.exists(path.join(__dirname, '..', 'vendor', name), function (exists) { fs.exists(path.join(__dirname, '..', 'vendor', name), function (exists) {
if (exists) { if (exists) {
...@@ -80,7 +105,7 @@ function fetch(name) { ...@@ -80,7 +105,7 @@ function fetch(name) {
download(url, dest, function(err) { download(url, dest, function(err) {
if (err) { if (err) {
console.error(err.message); console.error(err);
return; 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