Skip to content

Commit 5107d7d

Browse files
committed
Merge pull request #288 from meschbach/master
Optionally set report verbosity level using report option
2 parents 5f6f748 + eec87eb commit 5107d7d

File tree

2 files changed

+21
-4
lines changed

2 files changed

+21
-4
lines changed

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,11 +80,12 @@ Default: `false`
8080
Parse a single expression, rather than a program (for parsing JSON)
8181

8282
#### report
83-
Choices: `'min'`, `'gzip'`
83+
Choices: `false, 'none', 'min'`, `'gzip'`
8484
Default: `'min'`
8585

8686
Either report only minification result or report minification and gzip results.
8787
This is useful to see exactly how well clean-css is performing but using `'gzip'` will make the task take 5-10x longer to complete. [Example output](https://github.com/sindresorhus/maxmin#readme).
88+
If false or 'none' is used the report will be generated on the verbose output.
8889

8990
#### sourceMap
9091
Type: `Boolean`

tasks/uglify.js

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,20 @@ function relativePath(file1, file2) {
2424
return '';
2525
}
2626

27+
function reportFacility( grunt, options ){
28+
var reporter;
29+
switch( options.report ){
30+
case 'none':
31+
reporter = grunt.verbose;
32+
break;
33+
default:
34+
case 'min':
35+
case 'gzip':
36+
reporter = grunt.log;
37+
}
38+
return reporter;
39+
}
40+
2741
// Converts \r\n to \n
2842
function normalizeLf(string) {
2943
return string.replace(/\r\n/g, '\n');
@@ -50,6 +64,7 @@ module.exports = function(grunt) {
5064
screwIE8: false,
5165
quoteStyle: 0
5266
});
67+
var log = reportFacility( grunt, options );
5368

5469
// Process banner.
5570
var banner = normalizeLf(options.banner);
@@ -167,12 +182,13 @@ module.exports = function(grunt) {
167182
// Write source map
168183
if (options.sourceMap) {
169184
grunt.file.write(options.generatedSourceMapName, result.sourceMap);
170-
grunt.verbose.writeln('File ' + chalk.cyan(options.generatedSourceMapName) + ' created (source map).');
185+
log.writeln('File ' + chalk.cyan(options.generatedSourceMapName) + ' created (source map).');
171186
createdMaps++;
172187
}
173188

174-
grunt.verbose.writeln('File ' + chalk.cyan(f.dest) + ' created: ' +
175-
maxmin(result.max, output, options.report === 'gzip'));
189+
var outputSize = maxmin(result.max, output, options.report === 'gzip');
190+
log.writeln('File ' + chalk.cyan(f.dest) + ' created: ' + outputSize);
191+
176192
createdFiles++;
177193
});
178194

0 commit comments

Comments
 (0)