add whitespace option and move util.errorWithNode to File
This commit is contained in:
@@ -73,16 +73,6 @@ exports.getIds = function (node) {
|
||||
return ids;
|
||||
};
|
||||
|
||||
exports.errorWithNode = function (node, msg) {
|
||||
var line = node.loc.start.line;
|
||||
var col = node.loc.start.column;
|
||||
|
||||
var err = new SyntaxError("Line " + line + ": " + msg);
|
||||
err.lineNumber = line;
|
||||
err.column = col;
|
||||
return err;
|
||||
};
|
||||
|
||||
exports.canCompile = function (filename) {
|
||||
var ext = path.extname(filename);
|
||||
return _.contains([".js", ".es6"], ext);
|
||||
@@ -202,20 +192,14 @@ exports.repeat = function (width, cha) {
|
||||
|
||||
exports.parse = function (opts, code, callback) {
|
||||
try {
|
||||
var recastOpts = {};
|
||||
|
||||
if (opts.sourceMap) {
|
||||
recastOpts.sourceFileName = opts.sourceFileName;
|
||||
recastOpts.sourceRoot = opts.sourceRoot;
|
||||
}
|
||||
|
||||
var comments = [];
|
||||
var tokens = [];
|
||||
|
||||
var ast = acorn.parse(code, {
|
||||
ecmaVersion: Infinity,
|
||||
strictMode: true,
|
||||
onComment: comments,
|
||||
locations: true,
|
||||
locations: opts.sourceMap,
|
||||
onToken: tokens,
|
||||
ranges: true
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user