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

exitCode type does not match the one of nodejs 20 ? #82

Open
kapouer opened this issue May 24, 2024 · 1 comment
Open

exitCode type does not match the one of nodejs 20 ? #82

kapouer opened this issue May 24, 2024 · 1 comment

Comments

@kapouer
Copy link

kapouer commented May 24, 2024

(ask the cat why there is an initial empty issue - sorry for this)

It looks like there is a problem when building signal-exit on node 20 (on my debian env, with non-pristine nodejs stuff).

src/index.ts(304,34): error TS2345: Argument of type 'string | number | undefined' is not assignable to parameter of type 'number | null | undefined'.

@types/node 20.12.12 indeed has a different definition for process.exitCode.
It might very well be a problem only me is seeing, but it might not !

Miaw

@kapouer kapouer changed the title exitCode: exitCode type does not match the one of nodejs 20 ? May 24, 2024
@kapouer
Copy link
Author

kapouer commented May 26, 2024

This inelegantly fixes the issue:

--- a/src/index.ts
+++ b/src/index.ts
@@ -301,7 +301,8 @@
       /* c8 ignore start */
       const ret = og.call(this.#process, ev, ...args)
       /* c8 ignore start */
-      this.#emitter.emit('exit', this.#process.exitCode, null)
+      const code = this.#process.exitCode
+      this.#emitter.emit('exit', typeof code == "string" ? parseInt(code) : code, null)
       /* c8 ignore stop */
       return ret
     } else {

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

No branches or pull requests

1 participant