From 2cedc843a8dd9eb6abe5af7397a6da74a13203ac Mon Sep 17 00:00:00 2001 From: Christopher Monsanto Date: Mon, 12 Jan 2015 16:49:28 -0500 Subject: [PATCH] don't print traceback on syntax error in CLI --- bin/6to5/util.js | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/bin/6to5/util.js b/bin/6to5/util.js index 1adf6d5119..b4cd0141f4 100644 --- a/bin/6to5/util.js +++ b/bin/6to5/util.js @@ -20,7 +20,17 @@ exports.transform = function (filename, code, opts) { opts = _.extend(opts || {}, index.opts); opts.filename = filename; - var result = to5.transform(code, opts); + var result; + try { + result = to5.transform(code, opts); + } catch(e) { + if (e.name === "SyntaxError") { + console.error("SyntaxError:", e.message); + process.exit(1); + } else { + throw e; + } + } result.filename = filename; result.actual = code; return result;