Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(runtime): add op_set_exit_code #12911

Merged
merged 1 commit into from
Nov 27, 2021
Merged

Conversation

bnoordhuis
Copy link
Contributor

Set the exit code to use if none is provided to Deno.exit(), or when
Deno exits naturally.

Needed for process.exitCode Node compat. Paves the way for #12888.

* Deno.exit(); // Exits with status code 42.
* ```
*/
export function setExitCode(code: number): void;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not yet convinced we want to expose it as Deno API; maybe let's go with "hidden op" approach we discussed last time? Ie. there's an op to set it, but we don't expose it as Deno API right now.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It doesn't really matter when it's behind --unstable, I think?

At any rate, I can't seem to call Deno.core.opSync("op_set_exit_code", 42) from std/node. It doesn't show up in Deno.core.ops() (whereas e.g. op_exit does) and when I invoke it, I get this:

Uncaught TypeError: invalid op id: expected type `v8::data::Integer`, got `v8::data::Value`

(Which is a terribly misleading error message, by the way.)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay, belay that - it works after a full rebuild. I'll change it if you feel strongly but 🤷

Copy link
Member

@bartlomieju bartlomieju left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay, sure, let's go with unstable API. LGTM

Set the exit code to use if none is provided to Deno.exit(), or when
Deno exits naturally.

Needed for process.exitCode Node compat. Paves the way for denoland#12888.
@bnoordhuis
Copy link
Contributor Author

Decided to use an op after all. :-)

@bnoordhuis bnoordhuis changed the title feat(runtime): add Deno.setExitCode() feat(runtime): add op_set_exit_code Nov 27, 2021
@bnoordhuis bnoordhuis merged commit 993a1dd into denoland:main Nov 27, 2021
@bnoordhuis bnoordhuis deleted the set-exit-code branch November 27, 2021 23:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants