Skip to content

Instantly share code, notes, and snippets.

@webuniverseio
Created January 28, 2014 01:44
Show Gist options
  • Save webuniverseio/8660996 to your computer and use it in GitHub Desktop.
Save webuniverseio/8660996 to your computer and use it in GitHub Desktop.
/*jshint strict:false*/
/*global require:true, console:true, __dirname:true*/
var path = require('path'),
exec = require('child_process').exec,
//developmentFilesPath - relative path from this file to source folder, don't add trailing splash
developmentFilesPath = '..',
watcher = require('watch-tree-maintained').watchTree(path.join(__dirname, developmentFilesPath), {
match : /\.(scss|js)$/g
});
function handleProcessTermination(err, sysout, syserr) {
if (err) {
console.log(err + '\n');
}
if (sysout) {
console.log(sysout + '\n');
}
if (syserr) {
console.log(syserr + '\n');
}
}
function runCommand(command) {
exec(command, handleProcessTermination).stdin.end();
}
watcher.on('fileModified', function (path, stats) {
// if (~path.search(/\.scss$/)) {
// runCommand('compass compile');
// } else
if (~path.search(/\.js$/) && !~path.search(/build-js\//)) {
runCommand('node app.build.js');
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment