Commit 03bd9d01 by Adeel Mujahid

Merge pull request #540 from am11/master

Install: Removes excessive dependencies
parents 2471e73c 4f21cf11
...@@ -44,8 +44,6 @@ ...@@ -44,8 +44,6 @@
"dependencies": { "dependencies": {
"chalk": "^0.5.1", "chalk": "^0.5.1",
"cross-spawn": "^0.2.3", "cross-spawn": "^0.2.3",
"download": "^3.1.2",
"download-status": "^2.1.0",
"gaze": "^0.5.1", "gaze": "^0.5.1",
"get-stdin": "^3.0.0", "get-stdin": "^3.0.0",
"meow": "^2.0.0", "meow": "^2.0.0",
...@@ -53,7 +51,8 @@ ...@@ -53,7 +51,8 @@
"mocha": "^2.0.1", "mocha": "^2.0.1",
"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"
}, },
"devDependencies": { "devDependencies": {
"coveralls": "^2.11.1", "coveralls": "^2.11.1",
......
...@@ -119,7 +119,10 @@ function testBinary(options) { ...@@ -119,7 +119,10 @@ function testBinary(options) {
return build(options); return build(options);
} }
if (!process.env.SKIP_NODE_SASS_TESTS) { if (process.env.SKIP_NODE_SASS_TESTS) {
return;
}
fs.stat(path.join(__dirname, '..', 'vendor', options.bin, 'binding.node'), function (err) { fs.stat(path.join(__dirname, '..', 'vendor', options.bin, 'binding.node'), function (err) {
if (err) { if (err) {
return build(options); return build(options);
...@@ -153,7 +156,6 @@ function testBinary(options) { ...@@ -153,7 +156,6 @@ function testBinary(options) {
console.log('Binary is fine; exiting'); console.log('Binary is fine; exiting');
}); });
}); });
}
} }
/** /**
......
var fs = require('fs'), var fs = require('fs'),
path = require('path'), path = require('path'),
Download = require('download'), request = require('request'),
status = require('download-status'); mkdirp = require('mkdirp');
/**
* Download file, if succeded save, if not delete
*
* @param {String} url
* @param {String} dest
* @param {function} cb
* @api private
*/
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 returnError = function(err) {
fs.unlink(dest);
cb(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);
}
response.pipe(file);
file.on('finish', function() {
file.close(cb);
});
}).on('error', returnError);
req.end();
req.on('error', returnError);
};
/** /**
* Check if binaries exists * Check if binaries exists
...@@ -30,29 +64,28 @@ function exists() { ...@@ -30,29 +64,28 @@ function exists() {
*/ */
function fetch(name) { function fetch(name) {
var download = new Download({
extract: true,
mode: '777',
strip: 1
});
var url = [ var url = [
'https://raw.githubusercontent.com/sass/node-sass-binaries/v', 'https://raw.githubusercontent.com/sass/node-sass-binaries/v',
require('../package.json').version, '/', name, require('../package.json').version, '/', name,
'/binding.node' '/binding.node'
].join(''); ].join('');
var dir = path.join(__dirname, '..', 'vendor', name);
var dest = path.join(dir, 'binding.node');
download.get(url); mkdirp(dir, function(err) {
download.dest(path.join(__dirname, '..', 'vendor', name)); if (err) {
download.use(status()); console.error(err);
return;
}
download.run(function(err) { download(url, dest, function(err) {
if (err) { if (err) {
console.error(err.message); console.error(err.message);
return; return;
} }
console.log('Binary installed in ' + download.dest()); console.log('Binary downloaded and installed at ' + dest);
});
}); });
} }
......
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