From f53f424e6b751fb188039c8cc716cda82356afc2 Mon Sep 17 00:00:00 2001 From: joel Date: Tue, 23 Jan 2018 14:23:46 +0000 Subject: [PATCH] Add "displayLog" property to display (or not) the "Source map xxxxxx created" log and "File xxxxx created", and add a log with the total number of created files at the end --- tasks/concat.js | 10 +++++++++- tasks/lib/sourcemap.js | 4 +++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/tasks/concat.js b/tasks/concat.js index 81fd862..4012f67 100644 --- a/tasks/concat.js +++ b/tasks/concat.js @@ -60,6 +60,8 @@ module.exports = function(grunt) { sourceMap = false; } + var outputFiles = []; + // Iterate over all src-dest file pairs. this.files.forEach(function(f) { // Initialize source map objects. @@ -114,8 +116,14 @@ module.exports = function(grunt) { grunt.file.write(f.dest, src); // Print a success message. - grunt.verbose.write('File ' + chalk.cyan(f.dest) + ' created.'); + if (!!options.displayLog) { + grunt.verbose.write('File ' + chalk.cyan(f.dest) + ' created.'); + } + outputFiles.push(chalk.cyan(f.dest)); }); + + grunt.verbose.write(outputFiles.length + ' new files created.'); + }); }; diff --git a/tasks/lib/sourcemap.js b/tasks/lib/sourcemap.js index 6c36473..b8baec8 100644 --- a/tasks/lib/sourcemap.js +++ b/tasks/lib/sourcemap.js @@ -246,7 +246,9 @@ exports.init = function(grunt) { this.dest, JSON.stringify(newSourceMap, null, '') ); - grunt.verbose.writeln('Source map ' + chalk.cyan(this.dest) + ' created.'); + if (!!this.options.displayLog) { + grunt.verbose.writeln('Source map ' + chalk.cyan(this.dest) + ' created.'); + } };