When the newer task determines that a src file should not be included (because it has not been modified more recently than the corresponding dest file or the previous task run time), the user may still want this file to be processed. This happens when the src file "depends" on other files that might have been modified - e.g. a LESS file that imports another file.
To support this, the newer task can be configured with an override function. This function will be called for every file that would otherwise be considered "older." If the override function calls the provided callback with a truthy value, the file will be included for processing (or considered "newer").
The override function looks like this:
grunt.initConfig({
newer: {
options: {
override: function(details, include) {
// decide if the file should be included
include(true); // include everything!
}
}
} // other tasks ...
});
The function is called with 2 arguments:
details - Object
task - string The currently running task name.
target - string The currently running target name.
path - string The path to a src file that appears to be "older" (not modified since the time below).
time - Date The comparison time. For tasks with dest files, this is the modification time of the dest file. For tasks without dest files, this is the last successful run time of the same task.
include - function(boolean) A callback that determines whether this src file should be included. Call with true to include or false to exclude the file.
When the
newer
task determines that asrc
file should not be included (because it has not been modified more recently than the correspondingdest
file or the previous task run time), the user may still want this file to be processed. This happens when thesrc
file "depends" on other files that might have been modified - e.g. a LESS file that imports another file.To support this, the
newer
task can be configured with anoverride
function. This function will be called for every file that would otherwise be considered "older." If theoverride
function calls the provided callback with a truthy value, the file will be included for processing (or considered "newer").The
override
function looks like this:The function is called with 2 arguments:
Object
string
The currently running task name.string
The currently running target name.string
The path to asrc
file that appears to be "older" (not modified since the time below).Date
The comparison time. For tasks withdest
files, this is the modification time of thedest
file. For tasks withoutdest
files, this is the last successful run time of the same task.function(boolean)
A callback that determines whether thissrc
file should be included. Call withtrue
to include orfalse
to exclude the file.