velociraptor icon indicating copy to clipboard operation
velociraptor copied to clipboard

Feature request - Allow passing patterns to `watch`

Open bebraw opened this issue 4 years ago • 3 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 https://github.com/denoland/deno/issues/2401#issuecomment-859901801 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).

bebraw avatar Sep 22 '21 12:09 bebraw

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 avatar Sep 22 '21 19:09 umbopepato

@umbopepato Thanks for the heads up. I opened a feature request at https://github.com/denoland/deno/issues/12197 .

I guess another option would be to leverage https://deno.land/x/[email protected] . 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.

bebraw avatar Sep 23 '21 06:09 bebraw

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.

umbopepato avatar Sep 23 '21 07:09 umbopepato