From 1eb53dd13a46d01006831e3c78aff4d6cba91da5 Mon Sep 17 00:00:00 2001 From: Sebastian McKenzie Date: Thu, 26 Feb 2015 21:28:54 +1100 Subject: [PATCH] add try-catch to bin watching compilation - fixes #901 --- bin/babel/dir.js | 6 +++++- bin/babel/file.js | 6 +++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/bin/babel/dir.js b/bin/babel/dir.js index eb6cb7f3a5..2f29509708 100644 --- a/bin/babel/dir.js +++ b/bin/babel/dir.js @@ -64,7 +64,11 @@ module.exports = function (commander, filenames, opts) { _.each(["add", "change"], function (type) { watcher.on(type, function (filename) { var relative = path.relative(dirname, filename) || filename; - if (util.canCompile(filename)) write(filename, relative); + try { + if (util.canCompile(filename)) write(filename, relative); + } catch (err) { + console.error(err.stack); + } }); }); }); diff --git a/bin/babel/file.js b/bin/babel/file.js index 81ccf2a27e..a6a239345c 100644 --- a/bin/babel/file.js +++ b/bin/babel/file.js @@ -119,7 +119,11 @@ module.exports = function (commander, filenames) { }).on("all", function (type, filename) { if (type === "add" || type === "change") { console.log(type, filename); - walk(); + try { + walk(); + } catch (err) { + console.error(err.stack); + } } }); }