node-supervisor
node-supervisor copied to clipboard
Supervisor file watching seems to assume directories unless a .js is at the end?
I completely love supervisor, but there is one thing that could be better when I'm using it for automated rebuilds (like browserify).
If I have a build file called "build", and include it in the -w list, supervisor does not detect that the file changed.
supervisor -n exit -w ./js,./build -x ./build
I'm seeing this too. I have a .yaml file that holds config info. I'd like to watch that file and restart the app if the config changes. But supervisor seems to think that I want to watch a directory:
supervisor -e node,js,coffee,litcoffee,yaml --watch ./etc/add.config.yaml,./etc/add.coffee -x coffee ./etc/add.coffee
When it starts:
Watching directory '/Users/collumj/Work/gamma/etc/add.config.yaml' for changes.
Uhh, that's not a directory. If I make a change to that yaml file supervisor misses it -- it doesn't restart.
I think the simple solution to this is to require a trailing forward slash on directory watches:
supervisor -e node,js,coffee,litcoffee,yaml --watch ./etc/add/,./etc/add.coffee -x coffee ./etc/add.coffee
(this would watch all files in the ./etc/add
directory and the single file ./etc/add.coffee
)
28 days with no comment, guess I better find a workaround or a different app.
Maybe we should make a PR? How hard could it be?
I think you're right; looks like the important part starts around here: https://github.com/petruisfan/node-supervisor/blob/master/lib/supervisor.js#L310
Also, it appears that the "ownership" of this repo passed to petruisfan from isaacs just a few days ago. Hopefully petruisfan will comb the backlog soon.
Actually after looking at it I think it's just poor UX -- I added a console log to the part that iterates and creates file watchers (line 306 in supervisor.js) and it appears to be watching just the file but the UX is saying it's watching a directory.
Pass in the -V flag for details about file watching.
I think part of the problem is that one must use -e to make sure the extension of the file in question is filtered in to the list of watched files. I haven't yet confirmed whether "blank file extension" is supported (a case I happen to need).
See https://github.com/petruisfan/node-supervisor/blob/master/lib/supervisor.js line 340 - that callback always calls "watchGivenFile", but only when the extension matches.
But that makes sense: only watch a file if the file matches the extension pattern passed in. If you passed in an extension, I assume. If you specify a single file and an extension pattern and the file's extension doesn't match, well I guess throw an error?
Wow here it is nearly a year later and I ran into this again and this issue hasn't been touched. I have a yaml file in my root folder. I'd like to watch it for changes. I figured it out though, add -e
to your config for the supervisor call:
supervisor -w myProject.config.yaml,src -p 100 -e coffee,yaml -- --debug=5567 src/index.js