allow for multiple files to be associated with an array of strings

This commit is contained in:
eleith 2013-10-24 00:29:57 -07:00
parent 1f8582d05e
commit da1caf6bb7

View File

@ -61,19 +61,24 @@ exports.minify = function(files, options) {
output : null, output : null,
compress : {} compress : {}
}); });
if (typeof files == "string") if (typeof files == "string") {
files = [ files ]; files = [ files ];
if (options.fromFile !== null) {
option.fromFile = [options.fromFile];
}
}
UglifyJS.base54.reset(); UglifyJS.base54.reset();
// 1. parse // 1. parse
var toplevel = null; var toplevel = null;
files.forEach(function(file){ files.forEach(function(file, index){
var code = options.fromString var code = options.fromString
? file ? file
: fs.readFileSync(file, "utf8"); : fs.readFileSync(file, "utf8");
toplevel = UglifyJS.parse(code, { toplevel = UglifyJS.parse(code, {
filename: options.fromString ? options.fromFile || "?" : file, filename: options.fromString ? options.fromFile[index] || "?" : file,
toplevel: toplevel toplevel: toplevel
}); });
}); });