Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added detail.config as override function parameter #115

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
24 changes: 19 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@ The `newer` task determines which files to include for a specific task based on
* **details** - `Object`
* **task** - `string` The currently running task name.
* **target** - `string` The currently running target name.
* **config** - `Object` The currently running target config.
* **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.
Expand All @@ -138,12 +139,25 @@ Example use of the `override` option:
grunt.initConfig({
newer: {
options: {
override: function(detail, include) {
if (detail.task === 'less') {
checkForModifiedImports(detail.path, detail.time, include);
} else {
include(false);
override: function(detail, callback) {
var include;
// Check additional deps from target config
if (detail.config.deps) {
detail.config.deps.forEach(function(fn) {
var ts = fs.statSync(fn).mtime;
var difference = detail.time - ts;
if(difference < this.tolerance ) {
console.log(detail.path + ' has a newer dependency ' + fn);
include = true;
return false;
}
}, this);
}
// Check modified imports for less tasks
if (!include && detail.task === 'less') {
include = hasModifiedImports(detail.path, detail.time);
}
callback(include);
}
}
}
Expand Down
1 change: 1 addition & 0 deletions tasks/newer.js
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ function createTask(grunt) {
var details = {
task: taskName,
target: targetName,
config: config,
path: filePath,
time: time
};
Expand Down