Commit 0ab145fa by Michael Mifsud Committed by GitHub

Merge pull request #1849 from xzyfer/feat/no-git-in-build

Remove the git fallback
parents 46c0c2be 93eeed1b
...@@ -2,8 +2,7 @@ ...@@ -2,8 +2,7 @@
* node-sass: scripts/build.js * node-sass: scripts/build.js
*/ */
var pkg = require('../package.json'), var fs = require('fs'),
fs = require('fs'),
mkdir = require('mkdirp'), mkdir = require('mkdirp'),
path = require('path'), path = require('path'),
spawn = require('cross-spawn'), spawn = require('cross-spawn'),
...@@ -50,74 +49,6 @@ function afterBuild(options) { ...@@ -50,74 +49,6 @@ function afterBuild(options) {
} }
/** /**
* manageProcess
*
* @param {ChildProcess} proc
* @param {Function} cb
* @api private
*/
function manageProcess(proc, cb) {
var errorMsg = '';
proc.stderr.on('data', function(data) {
errorMsg += data.toString();
});
proc.on('close', function(code) {
cb(code === 0 ? null : { message: errorMsg });
});
}
/**
* initSubmodules
*
* @param {Function} cb
* @api private
*/
function initSubmodules(cb) {
console.log('Detected a git install');
console.log('Cloning LibSass into src/libsass');
var clone = spawn('git', ['clone', 'https://github.com/sass/libsass.git', './src/libsass']);
manageProcess(clone, function(err) {
if (err) {
cb(err);
return;
}
console.log('Checking out LibSass to', pkg.libsass);
var checkout = spawn('git', ['checkout', pkg.libsass], { cwd: './src/libsass' });
manageProcess(checkout, function(err) {
cb(err);
});
});
}
/**
* installGitDependencies
*
* @param {Function} cb
* @api private
*/
function installGitDependencies(options, cb) {
var libsassPath = './src/libsass';
if (process.env.LIBSASS_EXT || options.libsassExt) {
cb();
} else if (fs.access) { // node 0.12+, iojs 1.0.0+
fs.access(libsassPath, fs.R_OK, function(err) {
err && err.code === 'ENOENT' ? initSubmodules(cb) : cb();
});
} else { // node < 0.12
fs.exists(libsassPath, function(exists) {
exists ? cb() : initSubmodules(cb);
});
}
}
/**
* Build * Build
* *
* @param {Object} options * @param {Object} options
...@@ -125,37 +56,30 @@ function installGitDependencies(options, cb) { ...@@ -125,37 +56,30 @@ function installGitDependencies(options, cb) {
*/ */
function build(options) { function build(options) {
installGitDependencies(options, function(err) { var args = [require.resolve(path.join('node-gyp', 'bin', 'node-gyp.js')), 'rebuild', '--verbose'].concat(
if (err) { ['libsass_ext', 'libsass_cflags', 'libsass_ldflags', 'libsass_library'].map(function(subject) {
console.error(err.message); return ['--', subject, '=', process.env[subject.toUpperCase()] || ''].join('');
process.exit(1); })).concat(options.args);
}
var args = [require.resolve(path.join('node-gyp', 'bin', 'node-gyp.js')), 'rebuild', '--verbose'].concat(
['libsass_ext', 'libsass_cflags', 'libsass_ldflags', 'libsass_library'].map(function(subject) {
return ['--', subject, '=', process.env[subject.toUpperCase()] || ''].join('');
})).concat(options.args);
console.log('Building:', [process.execPath].concat(args).join(' ')); console.log('Building:', [process.execPath].concat(args).join(' '));
var proc = spawn(process.execPath, args, { var proc = spawn(process.execPath, args, {
stdio: [0, 1, 2] stdio: [0, 1, 2]
}); });
proc.on('exit', function(errorCode) { proc.on('exit', function(errorCode) {
if (!errorCode) { if (!errorCode) {
afterBuild(options); afterBuild(options);
return; return;
} }
if (errorCode === 127 ) { if (errorCode === 127 ) {
console.error('node-gyp not found!'); console.error('node-gyp not found!');
} else { } else {
console.error('Build failed with error code:', errorCode); console.error('Build failed with error code:', errorCode);
} }
process.exit(1); process.exit(1);
});
}); });
} }
......
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