From: Alberto González Palomo Date: Mon, 15 Jun 2015 16:03:06 +0000 (+0200) Subject: fromString option, use index from argument array for filename instead of "?" X-Git-Url: https://git.ndcode.org/public/gitweb.cgi?a=commitdiff_plain;h=4fba3e0b80c3d1a5df04fa524f550868443aa784;p=UglifyJS.git fromString option, use index from argument array for filename instead of "?" The index allows the caller to map things like parse errors back to the code chunk where they appeared. --- diff --git a/tools/node.js b/tools/node.js index cbe49e39..2eb90363 100644 --- a/tools/node.js +++ b/tools/node.js @@ -73,13 +73,13 @@ exports.minify = function(files, options) { } else { if (typeof files == "string") files = [ files ]; - files.forEach(function(file){ + files.forEach(function(file, i){ var code = options.fromString ? file : fs.readFileSync(file, "utf8"); sourcesContent[file] = code; toplevel = UglifyJS.parse(code, { - filename: options.fromString ? "?" : file, + filename: options.fromString ? i : file, toplevel: toplevel }); });