feat: Add Deno.exitCode API (#23609)

This commits adds the ability to set a would-be exit code 
for the Deno process without forcing an immediate exit, 
through the new `Deno.exitCode` API.

- **Implements `Deno.exitCode` getter and setter**: Adds support for
setting
and retrieving a would-be exit code via `Deno.exitCode`.
This allows for asynchronous cleanup before process termination 
without immediately exiting.
- **Ensures type safety**: The setter for `Deno.exitCode` validates that
the provided value is a number, throwing a TypeError if not, to ensure
that
only valid exit codes are set.

Closes to #23605

---------

Co-authored-by: Bartek Iwańczuk <biwanczuk@gmail.com>
This commit is contained in:
Luke Edwards 2024-05-29 16:16:27 -07:00 committed by GitHub
parent cf611fbf54
commit 13723f267e
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
20 changed files with 322 additions and 24 deletions

View file

@ -674,6 +674,14 @@ ObjectDefineProperties(finalDenoNs, {
return internals.future ? undefined : customInspect;
},
},
exitCode: {
get() {
return os.getExitCode();
},
set(value) {
os.setExitCode(value);
},
},
});
const {