if (!HOP(options.output, "code") || options.output.code) {
if (options.sourceMap) {
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({
file: options.sourceMap.filename,
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) {
var command = uglifyjscmd + " test/input/issue-1323/sample.js --source-map url=inline";