give sensible error against invalid input source map (#3044)
This commit is contained in:
@@ -165,7 +165,11 @@ function minify(files, options) {
|
|||||||
if (!HOP(options.output, "code") || options.output.code) {
|
if (!HOP(options.output, "code") || options.output.code) {
|
||||||
if (options.sourceMap) {
|
if (options.sourceMap) {
|
||||||
if (typeof options.sourceMap.content == "string") {
|
if (typeof options.sourceMap.content == "string") {
|
||||||
options.sourceMap.content = JSON.parse(options.sourceMap.content);
|
try {
|
||||||
|
options.sourceMap.content = JSON.parse(options.sourceMap.content);
|
||||||
|
} catch (ex) {
|
||||||
|
throw new Error("invalid input source map: " + options.sourceMap.content);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
options.output.source_map = SourceMap({
|
options.output.source_map = SourceMap({
|
||||||
file: options.sourceMap.filename,
|
file: options.sourceMap.filename,
|
||||||
|
|||||||
@@ -56,6 +56,18 @@ describe("bin/uglifyjs", function () {
|
|||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
it("Should give sensible error against invalid input source map", function(done) {
|
||||||
|
var command = uglifyjscmd + " test/mocha.js --source-map content=blah,url=inline";
|
||||||
|
|
||||||
|
exec(command, function (err, stdout, stderr) {
|
||||||
|
assert.ok(err);
|
||||||
|
assert.deepEqual(stderr.split(/\n/).slice(0, 2), [
|
||||||
|
"INFO: Using input source map: blah",
|
||||||
|
"ERROR: invalid input source map: blah",
|
||||||
|
]);
|
||||||
|
done();
|
||||||
|
});
|
||||||
|
});
|
||||||
it("Should append source map to output when using --source-map url=inline", function (done) {
|
it("Should append source map to output when using --source-map url=inline", function (done) {
|
||||||
var command = uglifyjscmd + " test/input/issue-1323/sample.js --source-map url=inline";
|
var command = uglifyjscmd + " test/input/issue-1323/sample.js --source-map url=inline";
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user