Skip to content

Commit

Permalink
- Added verboseReport
Browse files Browse the repository at this point in the history
  • Loading branch information
lmartorella committed Jun 19, 2024
1 parent 0ca056c commit 81d010a
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion tasks/concat.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,16 @@

'use strict';

const prettyPrint = num => {
if (num < 1024) {
return `${num} bytes`;
}
if (num < 1024 * 1024) {
return `${(num / 1024).toFixed(1)} kB`;
}
return `${(num / (1024 * 1024)).toFixed(1)} MB`;
}

module.exports = function(grunt) {

// Internal lib.
Expand All @@ -25,7 +35,8 @@ module.exports = function(grunt) {
process: false,
sourceMap: false,
sourceMapName: undefined,
sourceMapStyle: 'embed'
sourceMapStyle: 'embed',
verboseReport: false
});

// Normalize boolean options that accept options objects.
Expand Down Expand Up @@ -115,6 +126,9 @@ module.exports = function(grunt) {
sourceMapHelper.add(options.separator);
}
}
if (options.verboseReport) {
grunt.log.writeln(` bundling ${chalk.cyan(filepath)}, size ${prettyPrint(src.length)}`);
}
return src;
}).join(options.separator) + footer;

Expand Down

0 comments on commit 81d010a

Please sign in to comment.