allow for multiple files to be associated with an array of strings
This commit is contained in:
parent
1f8582d05e
commit
da1caf6bb7
|
|
@ -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
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user