don't print traceback on syntax error in CLI
This commit is contained in:
parent
aac7aac373
commit
2cedc843a8
@ -20,7 +20,17 @@ exports.transform = function (filename, code, opts) {
|
|||||||
opts = _.extend(opts || {}, index.opts);
|
opts = _.extend(opts || {}, index.opts);
|
||||||
opts.filename = filename;
|
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.filename = filename;
|
||||||
result.actual = code;
|
result.actual = code;
|
||||||
return result;
|
return result;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user