Commit 03bd9d01 by Adeel Mujahid

Merge pull request #540 from am11/master

Install: Removes excessive dependencies
parents 2471e73c 4f21cf11
......@@ -44,8 +44,6 @@
"dependencies": {
"chalk": "^0.5.1",
"cross-spawn": "^0.2.3",
"download": "^3.1.2",
"download-status": "^2.1.0",
"gaze": "^0.5.1",
"get-stdin": "^3.0.0",
"meow": "^2.0.0",
......@@ -53,7 +51,8 @@
"mocha": "^2.0.1",
"nan": "^1.3.0",
"object-assign": "^1.0.0",
"replace-ext": "0.0.1"
"replace-ext": "0.0.1",
"request": "^2.48.0"
},
"devDependencies": {
"coveralls": "^2.11.1",
......
......@@ -119,7 +119,10 @@ function testBinary(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) {
if (err) {
return build(options);
......@@ -153,7 +156,6 @@ function testBinary(options) {
console.log('Binary is fine; exiting');
});
});
}
}
/**
......
var fs = require('fs'),
path = require('path'),
Download = require('download'),
status = require('download-status');
request = require('request'),
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
......@@ -30,29 +64,28 @@ function exists() {
*/
function fetch(name) {
var download = new Download({
extract: true,
mode: '777',
strip: 1
});
var url = [
'https://raw.githubusercontent.com/sass/node-sass-binaries/v',
require('../package.json').version, '/', name,
'/binding.node'
].join('');
var dir = path.join(__dirname, '..', 'vendor', name);
var dest = path.join(dir, 'binding.node');
download.get(url);
download.dest(path.join(__dirname, '..', 'vendor', name));
download.use(status());
mkdirp(dir, function(err) {
if (err) {
console.error(err);
return;
}
download.run(function(err) {
download(url, dest, function(err) {
if (err) {
console.error(err.message);
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