fromString option, use index from argument array for filename instead of "?"
authorAlberto González Palomo <bugs@sentido-labs.com>
Mon, 15 Jun 2015 16:03:06 +0000 (18:03 +0200)
committerAlberto González Palomo <bugs@sentido-labs.com>
Mon, 15 Jun 2015 16:03:06 +0000 (18:03 +0200)
The index allows the caller to map things like parse errors back to the
code chunk where they appeared.

tools/node.js

index cbe49e3..2eb9036 100644 (file)
@@ -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
             });
         });