Skip to content

Commit

Permalink
Use mtime of dest file if it is more recent
Browse files Browse the repository at this point in the history
  • Loading branch information
tschaub committed Sep 7, 2013
1 parent 80c9ee6 commit 6a104e6
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion tasks/newer.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,21 @@ function createTask(grunt, any) {
// look for files that have been modified since last run
var previous = fs.statSync(stamp).mtime;
newerFiles = files.map(function(obj) {
var time;
/**
* It is possible that there is a dest file that has been created
* more recently than the last successful run. This would happen if
* a target with multiple dest files failed before all dest files were
* created. In this case, we don't need to re-run src files that map
* to dest files that were already created.
*/
if (obj.dest && grunt.file.exists(obj.dest)) {
time = Math.max(fs.statSync(obj.dest).mtime, previous);
} else {
time = previous;
}
var src = obj.src.filter(function(filepath) {
var newer = fs.statSync(filepath).mtime > previous;
var newer = fs.statSync(filepath).mtime > time;
if (newer) {
modified = true;
}
Expand Down

0 comments on commit 6a104e6

Please sign in to comment.