mirror of
https://github.com/denoland/deno.git
synced 2025-09-30 22:21:15 +00:00
feat(std/node): Add support for process.on("exit") (#8940)
This commit adds support for process.on("exit") by appending a listener to the unload event. Luckily, unload works pretty much the same as on("exit") since it won't schedule any additional work in the even loop either. This commit also solves an error in the Node implementation, since "process.argv" didn't contained the main module route as it was supposed to.
This commit is contained in:
parent
e0eb111e3e
commit
1f8b83ba1a
5 changed files with 276 additions and 106 deletions
19
std/node/process_exit_test.ts
Normal file
19
std/node/process_exit_test.ts
Normal file
|
@ -0,0 +1,19 @@
|
|||
import "./global.ts";
|
||||
|
||||
//deno-lint-ignore no-undef
|
||||
process.on("exit", () => {
|
||||
console.log(1);
|
||||
});
|
||||
|
||||
function unexpected() {
|
||||
console.log(null);
|
||||
}
|
||||
//deno-lint-ignore no-undef
|
||||
process.on("exit", unexpected);
|
||||
//deno-lint-ignore no-undef
|
||||
process.removeListener("exit", unexpected);
|
||||
|
||||
//deno-lint-ignore no-undef
|
||||
process.on("exit", () => {
|
||||
console.log(2);
|
||||
});
|
Loading…
Add table
Add a link
Reference in a new issue