I have been looking all over for an example of a way to use Grunt's watch module to perform a few steps in order when a file change occurs. I haven't found a good example of any of this, so if someone could point me in the right direction that would be great.
- Build TypeScript project (I have this working)
- Watch directories for file changes (this works too)
- Start running the compiled JavaScript in a node process, while still watching for file changes (what's the best way to do this via Grunt? The watch module seems to kick off the recompile task OK)
- On file change, stop the other running process, recompile, and restart when finished. Keep watching for changes (No idea on this one - the restart is the tricky part!)
I've tried a few different ways such as starting a child process with Grunt, but I always end up with dangling processes, locked up ports, misdirected STDIO, or other issues. I'd like for the child processes to be killed if the Grunt process exits.
Is there a good way to handle this? Thanks!