Open reduxdj opened 12 years ago
Seems to be a problem with watcher util, but the result is that coffee scripts are not being watched? Maybe just set up the -w param in coffeescript instead?
I'm not sure I understand what the issue is? Is the app crashing? Does anything re-compile?
The issue seems to be the watch-util which doesn't seem to work properly. Since coffeescript has it's own -watch parameter, maybe the watch-util shouldn't be used as it's buggy?
One of the other problems is hidden OS files on the mac aren't ignored either:
/Users/dj/skeleton_temp/node-backbone-skeleton/node_modules/watch-tree/lib/watchers/stat.js:148 throw err; ^ Error: ENOTDIR, not a directory '/Users/dj/skeleton_temp/node-backbone-skeleton/.DS_Store' quadcore-imac:node-backbone-skeleton dj$ node server.js Compiling all templates valuee[object Object] Starting compass with config file 'config/config.rb' Watching for changes under root '/Users/dj/skeletontemp/node-backbone-skeleton' to paths ["server.coffee","util/*/.coffee","config/**/.coffee","server-lib//.coffee","bootstrap/*/.coffee","models/**/.coffee","controllers//.coffee","views/*/.coffee","client-lib/**/.coffee","templates/_/.html"]
/Users/dj/skeleton_temp/node-backbone-skeleton/node_modules/watch-tree/lib/watchers/stat.js:148 throw err;
The hidden files issue is definitely a bug. A tricky one to fix since I use this code on Linux machines too. Perhaps just ignore all files that start with a '.'?
Compass and CoffeeScript both have their own -w
flags and it's possible that they are the better alternatives until I get the bugs sorted out in the watcher-util. BTW, the reason the watcher util exists in the first place was because I was tired of having to run/maintain/remember several separate watcher utilities. I wanted 'hot redeploy' to work for everything so long as server.js
was running. Perhaps a simple hack for the time being is just to have the watcher util run compass -w
and coffee -w
on your behalf :)
I've forked your project and I'm giving it crack, I am going to use the -w param and then handle the callback, that should be enough, and the the watch-util isn't necessary. What do you think?
Give it a shot. I'd love to know how it works for you.
One note: the watcher class also recompiles the underscore templates, which you won't get with any of the -w
watchers. To totally get rid of the watcher util, you'd need to find a different way to have templates hot reload. Perhaps inline them at request time when NODE_ENV=development
?
This might be helpful. I have switch out the watchTree to https://github.com/busterjs/fs-watch-tree. It works out really well. The relevant part that I change in watcher.coffee is:
watchTree: (root = '.', sampleRate = 1) => self = @ console.log "in watch tree root" root = path.resolve root console.log "Watching for changes under root '#{root}' to paths #{JSON.stringify _.keys @paths}" watcher = watchTree(root , exclude: ["node_modules", "~", "#", /^./] , (event) -> console.log in "watchertree" filPath = event.name if not event.isDirectory() if filPath and event.isModify() self.handleFile(filPath, 'modify') else if filPath and event.isDelete() self.handleFile(filPath, 'delete') else if filPath self.handleFile(filPath, "create") else console.log("Error no file name passed in to watcher.") else console.log("It is a directory we don't do anything.") )
And things just kind of fall in to place from there.
tarting compass with config file 'config/config.rb' Watching for changes under root '/Users/dj/node-backbone-skeleton' to paths ["server.coffee","util//.coffee","config//_.coffee","server-lib/_/.coffee","bootstrap//.coffee","models//_.coffee","controllers//.coffee","views/*/.coffee","client-lib/**/.coffee","templates//_.html"] /Users/dj/node-backbone-skeleton /Users/dj/node-backbone-skeleton/.DS_Store /Users/dj/node-backbone-skeleton/.sass-cache /Users/dj/node-backbone-skeleton/bootstrap /Users/dj/node-backbone-skeleton/client-lib /Users/dj/node-backbone-skeleton/compiled /Users/dj/node-backbone-skeleton/config /Users/dj/node-backbone-skeleton/controllers /Users/dj/node-backbone-skeleton/dependencies /Users/dj/node-backbone-skeleton/models /Users/dj/node-backbone-skeleton/node_modules /Users/dj/node-backbone-skeleton/npm-debug.log /Users/dj/node-backbone-skeleton/public /Users/dj/node-backbone-skeleton/server-lib /Users/dj/node-backbone-skeleton/server.coffee /Users/dj/node-backbone-skeleton/server.js /Users/dj/node-backbone-skeleton/stylesheets /Users/dj/node-backbone-skeleton/templates /Users/dj/node-backbone-skeleton/test /Users/dj/node-backbone-skeleton/util /Users/dj/node-backbone-skeleton/views /Users/dj/node-backbone-skeleton/.sass-cache/3c23c87091594c158f76bd5858712dfa4497aea9 /Users/dj/node-backbone-skeleton/.sass-cache/8bce6ed59d3bc31a6f029bf9067d9402c59289f2 /Users/dj/node-backbone-skeleton/.sass-cache/df57214f4d230f3c2ec681dd1967b9ccfd0e394d /Users/dj/node-backbone-skeleton/bootstrap/bootstrap.coffee /Users/dj/node-backbone-skeleton/bootstrap/namespace.coffee /Users/dj/node-backbone-skeleton/client-lib/Foo.coffee /Users/dj/node-backbone-skeleton/compiled/.DS_Store /Users/dj/node-backbone-skeleton/compiled/bootstrap /Users/dj/node-backbone-skeleton/compiled/controllers /Users/dj/node-backbone-skeleton/compiled/lib /Users/dj/node-backbone-skeleton/compiled/models /Users/dj/node-backbone-skeleton/compiled/templates /Users/dj/node-backbone-skeleton/compiled/views /Users/dj/node-backbone-skeleton/config/.DS_Store /Users/dj/node-backbone-skeleton/config/config.rb /Users/dj/node-backbone-skeleton/config/environment.coffee /Users/dj/node-backbone-skeleton/config/environment.js /Users/dj/node-backbone-skeleton/config/jammit.yml /Users/dj/node-backbone-skeleton/controllers/FooController.coffee Compiling template file 'templates/index.html' to 'compiled/templates' and adding it to templates object /Users/dj/node-backbone-skeleton/dependencies/backbone-min.js /Users/dj/node-backbone-skeleton/dependencies/jquery-1.6.1.min.js /Users/dj/node-backbone-skeleton/dependencies/underscore-min.js /Users/dj/node-backbone-skeleton/models/FooModel.coffee /Users/dj/node-backbone-skeleton/node_modules/.bin /Users/dj/node-backbone-skeleton/node_modules/.DS_Store /Users/dj/node-backbone-skeleton/node_modules/express /Users/dj/node-backbone-skeleton/node_modules/file /Users/dj/node-backbone-skeleton/node_modules/glob /Users/dj/node-backbone-skeleton/node_modules/settings /Users/dj/node-backbone-skeleton/node_modules/underscore /Users/dj/node-backbone-skeleton/node_modules/watch-tree
/Users/dj/node-backbone-skeleton/node_modules/watch-tree/lib/watchers/stat.js:152 throw err;