Skip to content
This repository was archived by the owner on Jul 24, 2024. It is now read-only.

Build related fixes #609

Merged
merged 3 commits into from
Jan 8, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 1 addition & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -314,11 +314,7 @@ Note `--importer` takes the (absolute or relative to pwd) path to a js file, whi

## Post-install Build

Install runs a series of Mocha tests to see if your machine can use the pre-built [libsass] which will save some time during install. If any tests fail it will build from source.

If you know the pre-built version will work and do not want to wait for the tests to run you can skip the tests by setting the environment variable `SKIP_NODE_SASS_TESTS` to true.

SKIP_NODE_SASS_TESTS=true npm install
Install runs only two Mocha tests to see if your machine can use the pre-built [libsass] which will save some time during install. If any tests fail it will build from source.

## Maintainers

Expand Down
18 changes: 4 additions & 14 deletions scripts/build.js
Original file line number Diff line number Diff line change
Expand Up @@ -115,33 +115,23 @@ function testBinary(options) {
return build(options);
}

if (process.env.SKIP_NODE_SASS_TESTS) {
return;
}

fs.stat(path.join(__dirname, '..', 'vendor', options.bin, 'binding.node'), function (err) {
if (err) {
return build(options);
}

console.log('`' + options.bin + '` exists; testing');

var total;
var failures;
var mocha = new Mocha({
ui: 'bdd',
timeout: 999999,
reporter: function(stats) {
total = stats.total;
failures = stats.failures;
}
timeout: 999999
});

mocha.addFile(path.resolve(__dirname, '..', 'test', 'api.js'));
mocha.run(function () {
if ((total - failures) * 100 / total < 90) {
mocha.grep(/should compile sass to css with file/).run(function (done) {
if (done !== 0) {
console.log([
'Problem with the binary: ' + failures + ' of ' + total + ' tests are failing.',
'Problem with the binary.',
'Manual build incoming.',
'Please consider contributing the release binary to https://github.com/sass/node-sass-binaries for npm distribution.'
].join('\n'));
Expand Down
30 changes: 21 additions & 9 deletions scripts/install.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,17 +43,11 @@ function download(url, dest, cb) {
*/

function getProxy() {
var result;

['https-proxy', 'proxy', 'http-proxy'].map(function(config) {
var result = ['https-proxy', 'proxy', 'http-proxy'].filter(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;
}
});
return proxy.code === 0 && validateProxyUrl(proxy.output.trim());
})[0];

if (result) {
return result;
Expand All @@ -63,6 +57,24 @@ function getProxy() {
return env.HTTPS_PROXY || env.https_proxy || env.HTTP_PROXY || env.http_proxy;
}

/**
* Validates Proxy URL
*
* @param {String} url
* @api private
*/

function validateProxyUrl(url) {
if (/\n/.test(url)) {
url = url.replace(/\r?\n+/, '\n').split('\n');
url = url[url.length - 3].trim(); // get the second last element.
}

return url !== 'null' &&
url !== 'undefined' &&
url === require('url').parse(url);
}

/**
* Check if binaries exists
*
Expand Down