Skip to content
This repository has been archived by the owner on Oct 19, 2023. It is now read-only.

Commit

Permalink
Emit compile errors instead of crashing.
Browse files Browse the repository at this point in the history
This allows either the transform or bundle streams to handle compile
errors.  Useful for watchify, where you don't want the watcher to crash.
  • Loading branch information
cesutherland committed Dec 3, 2014
1 parent 70984a5 commit 2250c5f
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,13 @@ function hbsfy(file, opts) {
buffer += chunk.toString();
},
function() {
var js = precompiler.precompile(buffer, opts && opts.precompilerOptions);
var js;
try {
js = precompiler.precompile(buffer, opts && opts.precompilerOptions);
} catch (e) {
this.emit('error', e);
return this.queue(null);
}
// Compile only with the runtime dependency.
var compiled = "// hbsfy compiled Handlebars template\n";
compiled += "var HandlebarsCompiler = " + compiler + ";\n";
Expand Down

0 comments on commit 2250c5f

Please sign in to comment.