Skip to content

Embed URL

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Handlebars and Coffeescript Watcher
function addSlashes( str ) {
return (str+'').replace(/([\\"'])/g, "\\$1").replace(/\0/g, "\\0");
}
var spawn = require('child_process').spawn;
var growl = require('growl');
var coffee = './node_modules/.bin/coffee';
var coffee_tasks = [];
var handlebars_tasks = [];
coffee_tasks.push(spawn(coffee, ['-cwo', 'static/js', 'static/coffee']));
coffee_tasks.push(spawn(coffee, ['-cwo', 'test', 'test/src']));
handlebars_tasks.push(spawn('node', ['./scripts/watch_handlebars.js']));
coffee_tasks.forEach(function(cmd) {
cmd.stdout.on('data', function (data) {
process.stdout.write(data)
// hack since coffee watcher doesn't output errors to STDERR
if (/^In /.test(data)) {
console.log('ERROR')
growl(data, { title: 'Coffeescript Error'})
}
})
cmd.stderr.on('data', function (data) {
console.log('ERROR')
process.stderr.write(data)
})
});
handlebars_tasks.forEach(function(cmd) {
cmd.stdout.on('data', function (data) {
process.stdout.write(data)
})
cmd.stderr.on('data', function (data) {
process.stderr.write('Handlebars Error:')
var err = data.toString().match(/\nError: .+\n(.*\n){3}/)
if (err && err[0]) {
data = err[0]
}
process.stderr.write(data)
data = addSlashes(data);
growl(data, { title: 'Handlebars Error'})
})
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.