Skip to content

Instantly share code, notes, and snippets.

@espadrine
Created October 30, 2014 15:31
Show Gist options
  • Save espadrine/0a75a543935673eed010 to your computer and use it in GitHub Desktop.
Save espadrine/0a75a543935673eed010 to your computer and use it in GitHub Desktop.
Remove dot files from ember-cli sane watcher's reach
--- node_modules/ember-cli/node_modules/broccoli-sane-watcher/index.js
+++ node_modules/ember-cli/node_modules/broccoli-sane-watcher/index.js
@@ -76,20 +76,19 @@
this.watched[dir] = watcher;
};
-Watcher.prototype.onFileChanged = function (filePath, root) {
- if (this.options.verbose) console.log('file changed', filePath);
- this.scheduleBuild(path.join(root, filePath));
-};
-
-Watcher.prototype.onFileAdded = function (filePath, root) {
- if (this.options.verbose) console.log('file added', filePath);
- this.scheduleBuild(path.join(root, filePath));
-};
+var filenameRegex = /^[^\.]/;
+function makeOnChanged (log) {
+ return function (filePath, root) {
+ if (filenameRegex.test(path.basename(filePath))) {
+ if (this.options.verbose) console.log(log, filePath);
+ this.scheduleBuild(path.join(root, filePath));
+ }
+ };
+}
-Watcher.prototype.onFileDeleted = function (filePath, root) {
- if (this.options.verbose) console.log('file deleted', filePath);
- this.scheduleBuild(path.join(root, filePath));
-};
+Watcher.prototype.onFileChanged = makeOnChanged('file changed');
+Watcher.prototype.onFileAdded = makeOnChanged('file added');
+Watcher.prototype.onFileDeleted = makeOnChanged('file deleted');
Watcher.prototype.triggerChange = function (hash) {
this.emit('change', hash);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment