Feature request - Allow passing patterns to `watch`
bebraw opened this issue · comments
It would be good to support patterns for watch
. I.e.
scripts.json
{
"scripts": {
"start": {
"cmd": "deno run --unstable mod.ts",
"watch": "*.ts,*.json"
},
}
}
Based on denoland/deno#2401 (comment) Deno supports deno run --watch=./**/*.ts,./**/*.tsx server.ts
kind of syntax.
Looking at the code, the command builder would have to be extended to support strings beyond booleans (case DenoOptions.watch: {
in code).
Hi @bebraw, thanks for the suggestion! 🙂
It looks like the --watch
options is still a boolean flag though. You can verify this by passing a file to --watch
which is not part of the entry point module graph and then edit that file. You'll see that only the entry point and its dependencies are watched. The example in the issue you linked is probably working because the watched .ts
files are already part of the module graph (and the value of the boolean flag is ignored I guess?).
@umbopepato Thanks for the heads up. I opened a feature request at denoland/deno#12197 .
I guess another option would be to leverage https://deno.land/x/watch@1.2.1 . I wonder if I could do that in user space even. In this case I would have to trigger whatever Deno's watch
is triggering right now and if we're lucky there's a programmatic hook for that.
Awesome, thank you @bebraw! Let's see what they say and sure, if the flag is not going to change we can evaluate a custom implementation.