Skip to content

Commit

Permalink
Preliminary support for issue #46. Not the whole thing yet.
Browse files Browse the repository at this point in the history
  • Loading branch information
cowboy committed Jul 4, 2012
1 parent 344c436 commit afe61e3
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
3 changes: 3 additions & 0 deletions lib/grunt/file.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@ file.isMatch = function(patterns, filepath) {
});
};

// List of changed / deleted file paths, generated by the watch task.
file._watchFiles = {changed: null, deleted: null};

// Return an array of all file paths that match the given wildcard patterns.
file.expand = function() {
var args = grunt.utils.toArray(arguments);
Expand Down
8 changes: 7 additions & 1 deletion tasks/watch.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,9 @@ module.exports = function(grunt) {
// File changes to be logged.
var changedFiles = {};

// List of changed / deleted file paths.
grunt.file._watchFiles = {changed: [], deleted: []};

// Define an alternate fail "warn" behavior.
grunt.fail.warnAlternate = function() {
grunt.task.clearQueue({untilMarker: true}).run(nameArgs);
Expand All @@ -73,8 +76,11 @@ module.exports = function(grunt) {
grunt.log.ok();
var fileArray = Object.keys(changedFiles);
fileArray.forEach(function(filepath) {
var status = changedFiles[filepath];
// Log which file has changed, and how.
grunt.log.ok('File "' + filepath + '" ' + changedFiles[filepath] + '.');
grunt.log.ok('File "' + filepath + '" ' + status + '.');
// Add filepath to grunt.file._watchFiles for grunt.file.expand* methods.
grunt.file._watchFiles[status === 'deleted' ? 'deleted' : 'changed'].push(filepath);
// Clear the modified file's cached require data.
grunt.file.clearRequireCache(filepath);
});
Expand Down

0 comments on commit afe61e3

Please sign in to comment.