Permalink
Browse files

Re-attach watchers on rename-event.

 - or it only works once.
  • Loading branch information...
1 parent bf174a6 commit 455190a87e170335aaa69490cc95f4c00153afba @magnars committed Mar 22, 2013
Showing with 6 additions and 5 deletions.
  1. +5 −3 lib/watch-for-changes.js
  2. +1 −2 package.json
@@ -1,9 +1,11 @@
var fs = require("fs");
function lintOnChange(linter, file) {
- fs.watch(file, function (event) {
- if (event === "change") {
- linter.checkFile(file);
+ var watcher = fs.watch(file, function (event) {
+ linter.checkFile(file);
+ if (event === "rename") {
+ watcher.close();
+ lintOnChange(linter, file);
}
});
}
View
@@ -22,8 +22,7 @@
"glob": "~3.0",
"growl": "~1.1",
"underscore": "~1.1",
- "when": "https://github.com/cujojs/when/tarball/1.0.2",
- "watch": "~0.6"
+ "when": "https://github.com/cujojs/when/tarball/1.0.2"
},
"devDependencies": {
"buster": "~0.6",

0 comments on commit 455190a

Please sign in to comment.