Skip to content
This repository has been archived by the owner on Apr 20, 2018. It is now read-only.

Commit

Permalink
Check if a file is really modified
Browse files Browse the repository at this point in the history
  • Loading branch information
snasc committed Dec 26, 2014
1 parent 89b2c8b commit 7eea8c2
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
2 changes: 2 additions & 0 deletions lib/fileprocessor.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
};
9 changes: 7 additions & 2 deletions tasks/usemin.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand All @@ -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' : '') + '.');
});
});

Expand Down

0 comments on commit 7eea8c2

Please sign in to comment.