aboutsummaryrefslogtreecommitdiff
path: root/test/mocha/cli.js
diff options
context:
space:
mode:
Diffstat (limited to 'test/mocha/cli.js')
-rw-r--r--test/mocha/cli.js33
1 files changed, 31 insertions, 2 deletions
diff --git a/test/mocha/cli.js b/test/mocha/cli.js
index 7f0bd79f..7385e477 100644
--- a/test/mocha/cli.js
+++ b/test/mocha/cli.js
@@ -1,9 +1,9 @@
var assert = require("assert");
var exec = require("child_process").exec;
-var readFileSync = require("fs").readFileSync;
+var fs = require("fs");
function read(path) {
- return readFileSync(path, "utf8");
+ return fs.readFileSync(path, "utf8");
}
describe("bin/uglifyjs", function () {
@@ -106,6 +106,35 @@ describe("bin/uglifyjs", function () {
done();
});
});
+ it("Should not load source map before finish reading from STDIN", function(done) {
+ var mapFile = "tmp/input.js.map";
+ try {
+ fs.mkdirSync("./tmp");
+ } catch (e) {
+ if (e.code != "EEXIST") throw e;
+ }
+ try {
+ fs.unlinkSync(mapFile);
+ } catch (e) {
+ if (e.code != "ENOENT") throw e;
+ }
+ var command = [
+ uglifyjscmd,
+ "--source-map", "content=" + mapFile,
+ "--source-map", "url=inline"
+ ].join(" ");
+
+ var child = exec(command, function(err, stdout) {
+ if (err) throw err;
+
+ assert.strictEqual(stdout, read("test/input/pr-3040/expect.js"));
+ done();
+ });
+ setTimeout(function() {
+ fs.writeFileSync(mapFile, read("test/input/pr-3040/input.js.map"));
+ child.stdin.end(read("test/input/pr-3040/input.js"));
+ }, 1000);
+ });
it("Should work with --keep-fnames (mangle only)", function (done) {
var command = uglifyjscmd + ' test/input/issue-1431/sample.js --keep-fnames -m';