Skip to content

Commit 3150ca2

Browse files
authored
Merge pull request #418 from gruntjs/beautify-obj
Fix `beautify` when passed as an object.
2 parents 5fc442f + 5923f5b commit 3150ca2

File tree

4 files changed

+23
-10
lines changed

4 files changed

+23
-10
lines changed

Gruntfile.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -374,6 +374,18 @@ module.exports = function(grunt) {
374374
'tmp/mangle.js': ['test/fixtures/src/simple.js']
375375
},
376376
mangle: true
377+
},
378+
beautify_Object: {
379+
files: {
380+
'tmp/beautify.js': ['test/fixtures/src/localization.js', 'test/fixtures/src/simple.js']
381+
},
382+
options: {
383+
beautify: {
384+
'ascii_only': true,
385+
'indent_start': 2,
386+
'max_line_len': 40
387+
}
388+
}
377389
}
378390
},
379391

tasks/lib/uglify.js

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -220,16 +220,6 @@ exports.init = function(grunt) {
220220
outputOptions.preamble = options.banner;
221221
}
222222

223-
if (options.beautify) {
224-
if (_.isObject(options.beautify)) {
225-
// beautify options sent as an object are merged
226-
// with outputOptions and passed to the OutputStream
227-
_.assign(outputOptions, options.beautify);
228-
} else {
229-
outputOptions.beautify = true;
230-
}
231-
}
232-
233223
if (options.screwIE8) {
234224
outputOptions.screw_ie8 = true;
235225
}
@@ -277,6 +267,14 @@ exports.init = function(grunt) {
277267
outputOptions.comments = options.preserveComments;
278268
}
279269

270+
if (options.beautify) {
271+
if (_.isObject(options.beautify)) {
272+
_.assign(outputOptions, options.beautify);
273+
} else {
274+
outputOptions.beautify = true;
275+
}
276+
}
277+
280278
return outputOptions;
281279
};
282280

test/fixtures/expected/beautify.js

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

test/uglify_test.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ exports.contrib_uglify = {
1212
preuglified_files: function(test) {
1313

1414
var files = [
15+
'beautify.js',
1516
'comments.js',
1617
'compress.js',
1718
'compress_explicit.js',

0 commit comments

Comments
 (0)