From 886ed42b7895bad9e7f974a22ea95fffdc94ceca Mon Sep 17 00:00:00 2001 From: Sebastian McKenzie Date: Mon, 29 Sep 2014 12:24:12 +1000 Subject: [PATCH] add util.errorWithNode method that returns an error with mapped location properties --- lib/6to5/util.js | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/lib/6to5/util.js b/lib/6to5/util.js index 93d1337f90..18d0d92019 100644 --- a/lib/6to5/util.js +++ b/lib/6to5/util.js @@ -36,6 +36,13 @@ exports.parse = function (code, opts) { } }; +exports.errorWithNode = function (node, msg) { + var err = new Error(msg); + err.lineNumber = node.loc.start.line; + err.column = node.loc.start.column; + return err; +}; + exports.canCompile = function (filename) { return path.extname(filename) === ".js"; };