Permalink
Browse files

fix handling dir wildcards in .foreverignore

  • Loading branch information...
1 parent 156f765 commit 2018d3aa583a24954cf08c66638737143d1ef297 Dmitry Petrov committed with indexzero Dec 11, 2012
@@ -20,12 +20,16 @@ exports.name = 'watch';
// is pretty messed up).
//
function watchFilter(fileName) {
+ var relFileName = path.relative(this.watchDirectory, fileName),
+ testName;
+
if (this.watchIgnoreDotFiles && path.basename(fileName)[0] === '.') {
return false;
}
for (var key in this.watchIgnorePatterns) {
- if (minimatch(fileName, this.watchIgnorePatterns[key], { matchBase: this.watchDirectory })) {
+ testName = (this.watchIgnorePatterns[key].charAt(0) !== '/') ? relFileName : fileName;
+ if (minimatch(testName, this.watchIgnorePatterns[key], { matchBase: this.watchDirectory })) {
return false;
}
}
@@ -40,7 +44,8 @@ function watchFilter(fileName) {
// Attaches functionality for logging stdout and stderr to `Monitor` instances.
//
exports.attach = function () {
- var monitor = this;
+ var monitor = this,
+ watchDirectory = this.watchDirectory;
fs.readFile(path.join(this.watchDirectory, '.foreverignore'), 'utf8', function (err, data) {
if (err) {
@@ -64,7 +69,9 @@ exports.attach = function () {
if (watchFilter.call(monitor, f)) {
monitor.emit('watch:restart', { file: f, stat: curr });
monitor.restart();
+ } else {
+ monitor.emit('watch:ignore', { file: f });
}
}
});
-};
+};
@@ -1,2 +1,3 @@
node_modules
ignore*
+ignoredDir/*
@@ -1,3 +1,4 @@
console.log('Hello!');
-setTimeout(process.exit, 2000);
+//timeout should be large enough to stay alive during the test
+setTimeout(process.exit, 20000);
@@ -0,0 +1 @@
+test
View
@@ -66,7 +66,16 @@ vows.describe('forever-monitor/plugins/watch').addBatch({
).split("\n")
);
}
+ },
+ 'when file in ignored dir is updated': {
+ topic: function (child) {
+ child.once('watch:ignore', this.callback);
+ fs.writeFileSync(path.join(__dirname, '..', 'fixtures', 'watch', 'ignore_newFile'), '');
+ },
+ 'do nothing': function (child, _) {
+ fs.unlinkSync(path.join(__dirname, '..', 'fixtures', 'watch', 'ignore_newFile'));
+ }
}
}
}
-}).export(module);
+}).export(module);

0 comments on commit 2018d3a

Please sign in to comment.