Wait for the postrun hook to finish (so auto-upgrade has a chance to run) and then
tree-kill the current process tree before exiting.
Long-running interactive commands like app dev need this when the user terminates
the command via q or Ctrl+C. The dev sub-processes such as servers and watchers keep
the event loop alive, so even after oclif's postrun hook completes the node process
won't exit on its own and we have to treeKill the process tree. We must not do that
before the postrun hook has actually finished running auto-upgrade, otherwise we would
kill the upgrade mid-way while npm install is still running.
The flag postRunHookCompleted is flipped at the very end of the hook after
autoUpgradeIfNeeded resolves, so polling it here is safe.
Wait for the postrun hook to finish (so auto-upgrade has a chance to run) and then tree-kill the current process tree before exiting.
Long-running interactive commands like
app devneed this when the user terminates the command viaqor Ctrl+C. The dev sub-processes such as servers and watchers keep the event loop alive, so even after oclif's postrun hook completes the node process won't exit on its own and we have totreeKillthe process tree. We must not do that before the postrun hook has actually finished running auto-upgrade, otherwise we would kill the upgrade mid-way whilenpm installis still running.The flag
postRunHookCompletedis flipped at the very end of the hook afterautoUpgradeIfNeededresolves, so polling it here is safe.