Commit dfa8c29a by xzyfer

Handle build script git operations in JS

parent 9cadba9b
......@@ -47,24 +47,47 @@ function afterBuild(options) {
}
/**
* initSubmodules
* manageProcess
*
* @param {ChildProcess} proc
* @param {Function} cb
* @api private
*/
function initSubmodules(cb) {
function manageProcess(proc, cb) {
var errorMsg = '';
var git = spawn(['LIBSASS_GIT_VERSION=', pkg.libsass, ' ./scripts/git.sh'].join(''));
git.stderr.on('data', function(data) {
proc.stderr.on('data', function(data) {
errorMsg += data.toString();
});
git.on('close', function(code) {
var error;
if (code !== 0) {
error = { message: errorMsg + 'Unable to checkout the libSass submodule' };
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', 'git@github.com:sass/libsass.git', './src/libsass']);
manageProcess(clone, function(err) {
if (err) {
cb(err);
return;
}
cb(error);
console.log('Checking out libsass to ' + pkg.libsass);
var checkout = spawn('git', ['checkout', pkg.libsass], { cwd: './src/libsass' });
manageProcess(checkout, function(err) {
cb(err);
});
});
}
......
#!/bin/sh
git clone --depth=1 git@github.com:sass/libsass.git ./src/libsass
cd ./src/libsass
git checkout $LIBSASS_GIT_VERSION
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