Should reload when the exact path is changed
Closed this issue · 3 comments
What version of Livereload are you using?
0.9.1
What OS are you using?
Ubuntu 18.04
What web browser are you using? (Browser name and specific version please)
Expected result
When I specify an exact file to watch livereload should ignore the extension filter.
Actual result
Reload does not trigger unless the extension is specified.
Steps to reproduce issue
In one terminal I start livereload with a specific file:
npx livereload file -d
Then touch the file:
touch file
The change is not picked up because the extension does not match the list. When I add an empty extension, it works:
npx livereload file -ee " " -d
Why is this important?
The current functionality is confusing. It makes sense when a whole directory is watched and only certain types of files are to be trigger the refresh, but for specific files it should be ignored.
I encountered this when I needed to watch an anonymous pipe like ... | npx livereload <(cat) -d
.
As I see, the extension check is here: https://github.com/napcs/node-livereload/blob/master/lib/livereload.coffee#L140 and the only change required is to pass the paths
from watch
and check if the filename
matches any of them exactly.
I can open a PR with this change but wanted to check if you would accept that.
@sashee This is an interesting use case. It's always been designed to watch a directory for changes. But as I consider what you're asking it also seems clear to me that it would also fail to watch changes to files without extensions at all unless the user did what you did and pass an empty extension.
Let me think about this for a bit before we move forward - part of me thinks that adding a specific flag for "files" instead of "dirs" would be better. Like npx livereload file -f
. Would that work for your needs?
Hi @napcs ,
yeah, a -f
option would work too. My only concern with the -ee " "
is that it is not supported with similar tools, for example it does not work with nodemon, and I'm afraid it is the result of a bug and sometime later it will be "fixed".
@sashee Hey hey. Sorry for the long delay.
0.9.2 is out now which adds support for the -f
option so you can list specific filenames to watch. This ended up being more universally useful than watching specific file paths, because this lets folks watch all files in any directory that match the given name.
It should work fine for your use case as well.
In addition, the arguments have been relaxed a lot so you don't have to specify the path as the first argument. This should make piping a little easier too.