Comparing version 0.1.0 to 0.1.1
@@ -42,2 +42,4 @@ /* | ||
var intervalId; | ||
// File changes to be logged. | ||
var changes = []; | ||
@@ -49,8 +51,16 @@ // Define an alternate fail "warn" behavior. | ||
// Cleanup when files have changed. | ||
function done(filepath) { | ||
// Cleanup when files have changed. This is debounced to handle situations | ||
// where editors save multiple files "simultaneously" and should wait until | ||
// all the files are saved. | ||
var done = underscore.debounce(function() { | ||
// Clear the files-added setInterval. | ||
clearInterval(intervalId); | ||
// Clear the modified file's cached require data. | ||
file.clearRequireCache(filepath); | ||
// Ok! | ||
log.ok(); | ||
changes.forEach(function(obj) { | ||
// Log which file has changed, and how. | ||
log.ok('File "' + obj.filepath + '" ' + obj.status + '.'); | ||
// Clear the modified file's cached require data. | ||
file.clearRequireCache(obj.filepath); | ||
}); | ||
// Unwatch all watched files. | ||
@@ -62,2 +72,9 @@ files.forEach(fs.unwatchFile); | ||
taskDone(); | ||
}, 250); | ||
function change(status, filepath) { | ||
// Push changes onto array for later logging. | ||
changes.push({filepath: filepath, status: status}); | ||
// Execute debounced done function. | ||
done(); | ||
} | ||
@@ -78,19 +95,18 @@ | ||
} | ||
// Log which file has changed. | ||
log.ok().ok('File "' + filepath + '" ' + status + '.'); | ||
// All done! | ||
done(filepath); | ||
// Call "change" for this file. | ||
change(status, filepath); | ||
}); | ||
}); | ||
// Files that have been added. | ||
var addedFiles = []; | ||
// Watch for files to be added. | ||
intervalId = setInterval(function() { | ||
var filepath = underscore.difference(getFiles(), files)[0]; | ||
if (filepath) { | ||
// Log which file has been added. | ||
log.ok().ok('File "' + filepath + '" added.'); | ||
// All done! | ||
done(filepath); | ||
} | ||
}, 500); | ||
// Files that have been added since last execution. | ||
var difference = underscore.difference(getFiles(), files, addedFiles); | ||
// Store added files for possible future "difference" test. | ||
addedFiles = addedFiles.concat(difference); | ||
// Call "change" once for each added file. | ||
difference.forEach(change.bind(this, 'added')); | ||
}, 200); | ||
}); |
@@ -5,3 +5,3 @@ { | ||
"description": "A command line build tool for JavaScript projects.", | ||
"version": "0.1.0", | ||
"version": "0.1.1", | ||
"homepage": "http://github.com/cowboy/grunt", | ||
@@ -8,0 +8,0 @@ "repository": { |
@@ -434,2 +434,3 @@ # grunt | ||
2012/01/19 - v0.1.1 - Minor 'watch' task tweak. | ||
2012/01/11 - v0.1.0 - Initial release. | ||
@@ -436,0 +437,0 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
102369
2191
441