#Chaining Tasks and using --watch

10 messages · Page 1 of 1 (latest)

slow flint
#

Is there a way to chain Deno tasks or something to that accord? I'd like to run esbuild from the command line to bundle/transpile some client JS and then have Deno start my dev webserver in watch mode. So each time a file is touched it runs esbuild and then Deno again.

silent coral
#

You could try out pup with the watch functionality and a chained command (never try chaining commands in pup, open an issue if it doesn't work)

https://github.com/Hexagon/pup/blob/main/docs/examples/watcher/pup.jsonc

Manual at https://hexagon.github.io/pup

Config should be something like this

{
  "processes": [
    {
      "id": "demo-watch",
      "cmd": ["deno", "run", "bundler.js", "&&", "deno", "run", "script.js"],
      "autostart": true, // When watching, we want autostart
      "restart": "always", // The process will just be killed when a file change is detected, configure to always restart
      "restartDelayMs": 1000, // Default is 10000, which is too long for development, set this to 1000
      "watch": ["./"] // Watch the entire current directory
    }
  ]
}
slow flint
#

This looks interesting. I will check it out - thanks

#

I was hoping there would be a more straight forward Deno way to do this though...

silent coral
#

If you want to avoid installing, you can run pup directly from the deno.land url and put everything in a deno task "deno task up", which would make it very slim

silent coral
#

Nope, chaining does not work using a single process in pup. Will have to work on that

slow flint
#

All good. I ended up compiling esbuild and calling it when initialising the app with Deno.run. I will come back and look at pup when the project goes into production. Thank you for your help

🙏