summaryrefslogtreecommitdiff
path: root/std/node/process_exit_test.ts
diff options
context:
space:
mode:
authorSteven Guerrero <stephenguerrero43@gmail.com>2021-01-25 11:30:31 -0500
committerGitHub <noreply@github.com>2021-01-25 17:30:31 +0100
commit1f8b83ba1aafd2c25c24c00eb7a117588a34b3f9 (patch)
tree5ab730abad715a1a0fd4cb3bc3ba8434ae4ab3c5 /std/node/process_exit_test.ts
parente0eb111e3e2f76d16682559780baa3d756ed0df7 (diff)
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.
Diffstat (limited to 'std/node/process_exit_test.ts')
-rw-r--r--std/node/process_exit_test.ts19
1 files changed, 19 insertions, 0 deletions
diff --git a/std/node/process_exit_test.ts b/std/node/process_exit_test.ts
new file mode 100644
index 000000000..54c8bcc01
--- /dev/null
+++ b/std/node/process_exit_test.ts
@@ -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);
+});