From 1b5f27077dd090a7bad6bb500415b051afde5fbe Mon Sep 17 00:00:00 2001 From: brettlangdon Date: Tue, 24 Jun 2014 12:51:33 -0400 Subject: [PATCH 1/2] remove watch dependency and add chokidar --- package.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index c1f6cc8..0959b7b 100644 --- a/package.json +++ b/package.json @@ -26,11 +26,11 @@ }, "homepage": "https://github.com/brettlangdon/tend", "dependencies": { - "watch": "~0.10.0", "docopt": "~0.4.0", "colors": "~0.6.2", "shell-quote": "~1.4.1", - "rc": "~0.4.0" + "rc": "~0.4.0", + "chokidar": "~0.8.2" }, "bin": { "tend": "bin/tend" From 51cfd2bdedf7e9b38907b736b20d100f68cac345 Mon Sep 17 00:00:00 2001 From: brettlangdon Date: Tue, 24 Jun 2014 12:52:22 -0400 Subject: [PATCH 2/2] use chokidar instead of watch --- lib/index.js | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/lib/index.js b/lib/index.js index 5b364a9..b2dd7aa 100644 --- a/lib/index.js +++ b/lib/index.js @@ -3,7 +3,7 @@ var parse = require('shell-quote').parse; var path = require('path'); var rc = require('rc'); var spawn = require('child_process').spawn; -var watch = require('watch'); +var chokidar = require('chokidar'); module.exports.tend = function(dir, rawCommand, options) { options = options || {}; @@ -46,16 +46,20 @@ module.exports.tend = function(dir, rawCommand, options) { console.log(('Process ' + pid + ' Started').green); }.bind(this); - if(options.start){ + if (options.start) { startCommand(); } - if(options.runOnce){ + if (options.runOnce) { return; } - watch.watchTree(dir, function(f, curr, prev) { - if (curr === null && prev === null) { + var ignoreEvents = ['add', 'addDir']; + chokidar.watch(dir, { + persistent: true + }) + .on('all', function(e, f) { + if (~ignoreEvents.indexOf(e)) { return; } if (ignoreHidden) { @@ -64,6 +68,7 @@ module.exports.tend = function(dir, rawCommand, options) { return; } } + if (!filter.test(f)) { return; }