Skip to content

Commit

Permalink
Clean up banner option.
Browse files Browse the repository at this point in the history
  • Loading branch information
XhmikosR committed Mar 31, 2017
1 parent bbe1da0 commit f161c6d
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 9 deletions.
9 changes: 7 additions & 2 deletions tasks/lib/uglify.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,11 @@ var assign = require('object.assign');
var uriPath = require('uri-path');
var getOutputOptions;

// Converts \r\n to \n
function normalizeLf(string) {
return string.replace(/\r\n/g, '\n');
}

exports.init = function(grunt) {
var exports = {};

Expand Down Expand Up @@ -228,8 +233,8 @@ exports.init = function(grunt) {
source_map: null
};

if (options.banner && options.sourceMap) {
outputOptions.preamble = options.banner;
if (options.banner) {
outputOptions.preamble = normalizeLf(options.banner);
}

if (options.screwIE8 === false) {
Expand Down
7 changes: 0 additions & 7 deletions tasks/uglify.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,6 @@ module.exports = function(grunt) {
});
var log = reportFacility(grunt, options);

// Process banner.
var banner = normalizeLf(options.banner);
var footer = normalizeLf(options.footer);
var mapNameGenerator, mapInNameGenerator;
var createdFiles = 0;
Expand Down Expand Up @@ -171,11 +169,6 @@ module.exports = function(grunt) {
// Concat minified source + footer
var output = result.min + footer;

// Only prepend banner if uglify hasn't taken care of it as part of the preamble
if (!options.sourceMap) {
output = banner + output;
}

// Write the destination file.
grunt.file.write(f.dest, output);

Expand Down
1 change: 1 addition & 0 deletions test/fixtures/expected/compress_mangle_banner.js
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
// banner without sourcemap

function longFunctionC(a,b){return longNameA+longNameB+a+b}var longNameA=1,longNameB=2,result=longFunctionC(3,4);

0 comments on commit f161c6d

Please sign in to comment.