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.
This commit is contained in:
Alberto González Palomo
2015-06-15 18:03:06 +02:00
parent 5bf617ebde
commit 4fba3e0b80

View 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
});
});