Filirom1/watch-connect — pull request #1 by dbashford (2012-06-20 21:01:19+00:00)
Title: Working with express

A few quick edits. First, this library depends on connect and it was missing from the package.json. With my express app, I don't include connect, no need, so watch-connect broke straight away.

Next up, I want to be able to use this with express, but the way the watch-connect code works, it takes the requested file (public/index.html for instance) and attempts to find it in the file system so it can edit it on the way back to the server. But in the case of a typical express app, there is no index.html, its all jade. So the files never get added. The workaround for me is to add the scripts themselves right to my layout.jade. And I can easily wrap a flag around them so they aren't added in development, or something of that sort. So its not a workaround as much as a quality solution in this case.

I added a skipAdding option, which simply stops the attempt to add the scripts to outgoing .html files. I realized after I made the change and tested it out, that for a typical express app this is really just a performance improvement since there aren't any outgoing .html files. But should someone else want to add the files by hand, its a nice option to have, to not have them added again. And it takes a bit of the magic out for those opposed to too much magic. =)

Thanks much!