Skip to content

Commit

Permalink
fix CLI parsing of --source-map content (#2088)
Browse files Browse the repository at this point in the history
fixes #2082
  • Loading branch information
zaygraveyard authored and alexlamsl committed Jun 13, 2017
1 parent 3dc9e14 commit 82db918
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 1 deletion.
2 changes: 1 addition & 1 deletion bin/uglifyjs
Expand Up @@ -371,7 +371,7 @@ function parse_js(flag, constants) {
function parse_source_map() {
var parse = parse_js("sourceMap", true);
return function(value, options) {
var hasContent = options && options.sourceMap && "content" in options.sourceMap;
var hasContent = options && "content" in options;
var settings = parse(value, options);
if (!hasContent && settings.content && settings.content != "inline") {
print_error("INFO: Using input source map: " + settings.content);
Expand Down
1 change: 1 addition & 0 deletions test/input/issue-2082/sample.js
@@ -0,0 +1 @@
console.log(x);
1 change: 1 addition & 0 deletions test/input/issue-2082/sample.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

17 changes: 17 additions & 0 deletions test/mocha/cli.js
Expand Up @@ -77,6 +77,23 @@ describe("bin/uglifyjs", function () {
done();
});
});
it("should not consider source map file content as source map file name (issue #2082)", function (done) {
var command = [
uglifyjscmd,
"test/input/issue-2082/sample.js",
"--source-map", "content=test/input/issue-2082/sample.js.map",
"--source-map", "url=inline",
].join(" ");

exec(command, function (err, stdout, stderr) {
if (err) throw err;

var stderrLines = stderr.split('\n');
assert.strictEqual(stderrLines[0], 'INFO: Using input source map: test/input/issue-2082/sample.js.map');
assert.notStrictEqual(stderrLines[1], 'INFO: Using input source map: {"version": 3,"sources": ["index.js"],"mappings": ";"}');
done();
});
});
it("Should work with --keep-fnames (mangle only)", function (done) {
var command = uglifyjscmd + ' test/input/issue-1431/sample.js --keep-fnames -m';

Expand Down

0 comments on commit 82db918

Please sign in to comment.