fix missing preamble when shebang is absent (#1742)
This commit is contained in:
@@ -510,8 +510,8 @@ function OutputStream(options) {
|
|||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (comments.length > 0 && output.pos() == 0) {
|
if (output.pos() == 0) {
|
||||||
if (output.option("shebang") && comments[0].type == "comment5") {
|
if (comments.length > 0 && output.option("shebang") && comments[0].type == "comment5") {
|
||||||
output.print("#!" + comments.shift().value + "\n");
|
output.print("#!" + comments.shift().value + "\n");
|
||||||
output.indent();
|
output.indent();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -79,5 +79,13 @@ describe("comment filters", function() {
|
|||||||
output: { preamble: "/* Build */" }
|
output: { preamble: "/* Build */" }
|
||||||
}).code;
|
}).code;
|
||||||
assert.strictEqual(code, "#!/usr/bin/node\n/* Build */\nvar x=10;");
|
assert.strictEqual(code, "#!/usr/bin/node\n/* Build */\nvar x=10;");
|
||||||
})
|
});
|
||||||
|
|
||||||
|
it("Should handle preamble without shebang correctly", function() {
|
||||||
|
var code = UglifyJS.minify("var x = 10;", {
|
||||||
|
fromString: true,
|
||||||
|
output: { preamble: "/* Build */" }
|
||||||
|
}).code;
|
||||||
|
assert.strictEqual(code, "/* Build */\nvar x=10;");
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user