I'm putting together a build task for a project using node-sass. I'm creating a watcher which recompiles sass when files change, using gulp.watch
The problem I'm encountering is that when I use renderSync, the watcher crashes if it encounters any build problems - the sass compile errors dump out and the watcher terminates.
If I use render, I'm able to catch build errors and provide helpful output, but of course now I'm not sure how to execute some logic at the end of the build. I want to be able to gracefully handle compile failures, but still execute the whole process synchronously.
Is this possible? I can imagine reasons it wouldn't be, but I'd like to hear from a contributor. What's my plan of attack?
var sass = require('node-sass');
var css;
try {
css = sass.renderSync();
console.log('success');
} catch (err) {
console.log('failure');
}