Closed warang580 closed 8 years ago
While the tests pass, it's because there is no coverage for the copying system (because it's a hack, not actual behavior of stimpak).
process.on("exit") does not allow asynchronous tasks to happen, so all callbacks are ignored, meaning that the cleanup task never actually happens (and we don't see that in the tests because there isn't a test to check if the cleanup actually occurred, again because this is hacky behavior and I intend to replace it with the absolute minimal solution, then codify it as a spec.
Try it out yourself, and see how the generator gets moved to /generators, then never gets put back.
I'm not sure if there's a good way to reliably cleanup with node 0.10, considering a Ctrl-C can short circuit the whole process and exit before cleanup.
We could try process.on("SIGINT"
Looks like there's a bug that affects all libraries that utilizes readline (like inquirer.js) that prevents us from using the SIGINT hook: https://github.com/nodejs/node/issues/4758
Until this bug is fixed, the entire cleanup sequence must be made synchronous to avoid the issue where the event loop quits taking new events, or we simply cannot support Node 0.10.
Tests were failing because it couldn't move global generators (rename directories) into stimpak
generators/
folder because they already were there. After some search, I found that generators were not cleaned because it never catches thebeforeExit
event, because it doesn't exist in Node v.0.10 - so global generators were never moved back after use.You don't need to
process.exit()
when listening toexit
(as it was forbeforeExit
) because it's already too late, the process is about to stop and you can't prevent it.