Skip to content

Commit

Permalink
Fix beautify when passed as an object.
Browse files Browse the repository at this point in the history
  • Loading branch information
XhmikosR committed Jul 13, 2016
1 parent 5fc442f commit 5923f5b
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 10 deletions.
12 changes: 12 additions & 0 deletions Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -374,6 +374,18 @@ module.exports = function(grunt) {
'tmp/mangle.js': ['test/fixtures/src/simple.js']
},
mangle: true
},
beautify_Object: {
files: {
'tmp/beautify.js': ['test/fixtures/src/localization.js', 'test/fixtures/src/simple.js']
},
options: {
beautify: {
'ascii_only': true,
'indent_start': 2,
'max_line_len': 40
}
}
}
},

Expand Down
18 changes: 8 additions & 10 deletions tasks/lib/uglify.js
Original file line number Diff line number Diff line change
Expand Up @@ -220,16 +220,6 @@ exports.init = function(grunt) {
outputOptions.preamble = options.banner;
}

if (options.beautify) {
if (_.isObject(options.beautify)) {
// beautify options sent as an object are merged
// with outputOptions and passed to the OutputStream
_.assign(outputOptions, options.beautify);
} else {
outputOptions.beautify = true;
}
}

if (options.screwIE8) {
outputOptions.screw_ie8 = true;
}
Expand Down Expand Up @@ -277,6 +267,14 @@ exports.init = function(grunt) {
outputOptions.comments = options.preserveComments;
}

if (options.beautify) {
if (_.isObject(options.beautify)) {
_.assign(outputOptions, options.beautify);
} else {
outputOptions.beautify = true;
}
}

return outputOptions;
};

Expand Down
2 changes: 2 additions & 0 deletions test/fixtures/expected/beautify.js

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

1 change: 1 addition & 0 deletions test/uglify_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ exports.contrib_uglify = {
preuglified_files: function(test) {

var files = [
'beautify.js',
'comments.js',
'compress.js',
'compress_explicit.js',
Expand Down

0 comments on commit 5923f5b

Please sign in to comment.