diff options
-rw-r--r-- | test/input/issue-1242/bar.es5 | 4 | ||||
-rw-r--r-- | test/input/issue-1242/baz.es5 | 4 | ||||
-rw-r--r-- | test/input/issue-1242/foo.es5 | 5 | ||||
-rw-r--r-- | test/input/issue-1242/qux.js | 4 | ||||
-rw-r--r-- | test/mocha/glob.js | 28 | ||||
-rw-r--r-- | tools/node.js | 1 |
6 files changed, 46 insertions, 0 deletions
diff --git a/test/input/issue-1242/bar.es5 b/test/input/issue-1242/bar.es5 new file mode 100644 index 00000000..6e308a30 --- /dev/null +++ b/test/input/issue-1242/bar.es5 @@ -0,0 +1,4 @@ +function bar(x) { + var triple = x * (2 + 1); + return triple; +} diff --git a/test/input/issue-1242/baz.es5 b/test/input/issue-1242/baz.es5 new file mode 100644 index 00000000..83c98ef6 --- /dev/null +++ b/test/input/issue-1242/baz.es5 @@ -0,0 +1,4 @@ +function baz(x) { + var half = x / 2; + return half; +} diff --git a/test/input/issue-1242/foo.es5 b/test/input/issue-1242/foo.es5 new file mode 100644 index 00000000..4b439075 --- /dev/null +++ b/test/input/issue-1242/foo.es5 @@ -0,0 +1,5 @@ +var print = console.log.bind(console); +function foo(x) { + var twice = x * 2; + print('Foo:', twice); +} diff --git a/test/input/issue-1242/qux.js b/test/input/issue-1242/qux.js new file mode 100644 index 00000000..94171f38 --- /dev/null +++ b/test/input/issue-1242/qux.js @@ -0,0 +1,4 @@ +var a = bar(1+2); +var b = baz(3+9); +print('q' + 'u' + 'x', a, b); +foo(5+6); diff --git a/test/mocha/glob.js b/test/mocha/glob.js new file mode 100644 index 00000000..c2fc9464 --- /dev/null +++ b/test/mocha/glob.js @@ -0,0 +1,28 @@ +var Uglify = require('../../'); +var assert = require("assert"); + +describe("minify() with input file globs", function() { + it("minify() with one input file glob string.", function() { + var result = Uglify.minify("test/input/issue-1242/foo.*", { + compress: { collapse_vars: true } + }); + assert.strictEqual(result.code, 'function foo(o){print("Foo:",2*o)}var print=console.log.bind(console);'); + }); + it("minify() with an array of one input file glob.", function() { + var result = Uglify.minify([ + "test/input/issue-1242/b*.es5", + ], { + compress: { collapse_vars: true } + }); + assert.strictEqual(result.code, 'function bar(n){return 3*n}function baz(n){return n/2}'); + }); + it("minify() with an array of multiple input file globs.", function() { + var result = Uglify.minify([ + "test/input/issue-1242/???.es5", + "test/input/issue-1242/*.js", + ], { + compress: { collapse_vars: true } + }); + assert.strictEqual(result.code, 'function bar(n){return 3*n}function baz(n){return n/2}function foo(n){print("Foo:",2*n)}var print=console.log.bind(console);print("qux",bar(3),baz(12)),foo(11);'); + }); +}); diff --git a/tools/node.js b/tools/node.js index 5a143759..6712ccf6 100644 --- a/tools/node.js +++ b/tools/node.js @@ -73,6 +73,7 @@ exports.minify = function(files, options) { bare_returns: options.parse ? options.parse.bare_returns : undefined }); } + if (!options.fromString) files = UglifyJS.simple_glob(files); [].concat(files).forEach(function (files, i) { if (typeof files === 'string') { addFile(files, options.fromString ? i : files); |