aboutsummaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
authorGeraint <luffgd@gmail.com>2016-06-27 12:01:21 +0100
committerRichard van Velzen <rvanvelzen1@gmail.com>2016-06-30 22:23:59 +0200
commit85924bb32e1c27f555aad1651f4575b45bcbadb1 (patch)
treed50d1032e48adff2e748ce9ac9d90fb7c339a7f6 /tools
parenta97690fc724a7beba77d7fde449ea56676804933 (diff)
downloadtracifyjs-85924bb32e1c27f555aad1651f4575b45bcbadb1.tar.gz
tracifyjs-85924bb32e1c27f555aad1651f4575b45bcbadb1.zip
Allow input files to be map (url->filename)
Diffstat (limited to 'tools')
-rw-r--r--tools/node.js17
1 files changed, 12 insertions, 5 deletions
diff --git a/tools/node.js b/tools/node.js
index 39976371..2ee7df21 100644
--- a/tools/node.js
+++ b/tools/node.js
@@ -61,18 +61,25 @@ exports.minify = function(files, options) {
if (options.spidermonkey) {
toplevel = UglifyJS.AST_Node.from_mozilla_ast(files);
} else {
- if (typeof files == "string")
- files = [ files ];
- files.forEach(function(file, i){
+ function addFile(file, fileUrl) {
var code = options.fromString
? file
: fs.readFileSync(file, "utf8");
- sourcesContent[file] = code;
+ sourcesContent[fileUrl] = code;
toplevel = UglifyJS.parse(code, {
- filename: options.fromString ? i : file,
+ filename: fileUrl,
toplevel: toplevel,
bare_returns: options.parse ? options.parse.bare_returns : undefined
});
+ }
+ [].concat(files).forEach(function (files, i) {
+ if (typeof files === 'string') {
+ addFile(files, options.fromString ? i : files);
+ } else {
+ for (var fileUrl in files) {
+ addFile(files[fileUrl], fileUrl);
+ }
+ }
});
}
if (options.wrap) {