elekram
elekramā€¢16mo ago

Chaining Tasks and using --watch

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.
7 Replies
Hexagon
Hexagonā€¢16mo ago
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
}
]
}
{
"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
}
]
}
elekram
elekramā€¢16mo ago
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...
NDH
NDHā€¢16mo ago
Pup ^
Hexagon
Hexagonā€¢16mo ago
It could be done with a one liner too (if it works at all right now), check out the "single command usage" section of https://hexagon.github.io/pup/usage.html#single-command-usage
Pup - The Manual
Usage
Universal Process Manager
Hexagon
Hexagonā€¢16mo ago
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 Nope, chaining does not work using a single process in pup. Will have to work on that
elekram
elekramā€¢16mo ago
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 šŸ™
NDH
NDHā€¢16mo ago
I have a dev server that might interest you. https://github.com/nhrones/HotServe Added preact jsx to HotServe example