diff --git a/lib/fileprocessor.js b/lib/fileprocessor.js index 46edb7e..c4421e2 100644 --- a/lib/fileprocessor.js +++ b/lib/fileprocessor.js @@ -233,5 +233,7 @@ FileProcessor.prototype.process = function (filename, assetSearchPath) { var content = this.replaceWithRevved(this.replaceBlocks(this.file), this.file.searchPath); + this.isFileModified = !!this.file.blocks.length || (this.file.content !== content); + return content; }; diff --git a/tasks/usemin.js b/tasks/usemin.js index 844dbde..99f5a55 100644 --- a/tasks/usemin.js +++ b/tasks/usemin.js @@ -134,6 +134,7 @@ module.exports = function (grunt) { nonull: true, filter: 'isFile' }, fileObj.src); + var fileModified = 0; files.forEach(function (filename) { debug('looking at file %s', filename); @@ -142,14 +143,18 @@ module.exports = function (grunt) { // Our revved version locator var content = handler.process(filename, options.assetsDirs); - // write the new content to disk - grunt.file.write(filename, content); + if (handler.isFileModified) { + // write the new content to disk + grunt.file.write(filename, content); + fileModified++; + } }); grunt.log.writeln('Replaced ' + chalk.cyan(files.length) + ' ' + (files.length === 1 ? 'reference' : 'references') + ' to assets' ); + grunt.log.writeln('Real changed ' + chalk.cyan(fileModified) + ' file' + (fileModified > 1 ? 's' : '') + '.'); }); });