Skip to content

Add promise-based IPC #1059

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

Merged
merged 1 commit into from
May 16, 2024
Merged

Add promise-based IPC #1059

merged 1 commit into from
May 16, 2024

Conversation

ehmicky
Copy link
Collaborator

@ehmicky ehmicky commented May 16, 2024

Fixes #1053.

This adds the following methods:

  • In the current process: subprocess.sendMessage(message), subprocess.getOneMessage(), subprocess.getEachMessage().
  • In the subprocess, Execa exports the following methods instead: sendMessage(message), getOneMessage(), getEachMessage().

This also exports a new type Message representing IPC messages.

The old IPC methods are undocumented but kept. This PR does not have any breaking change.

Verified

This commit was signed with the committer’s verified signature. The key has expired.
@@ -70,7 +70,6 @@
"c8": "^9.1.0",
"get-node": "^15.0.0",
"is-running": "^2.1.0",
"p-event": "^6.0.0",
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

devDependencies used only in tests. Replaced by once() from node:events.

[More info.](https://nodejs.org/api/child_process.html#subprocesssendmessage-sendhandle-options-callback)
*/
send: HasIpc<OptionsType> extends true ? ChildProcess['send'] : undefined;
Copy link
Collaborator Author

@ehmicky ehmicky May 16, 2024

Choose a reason for hiding this comment

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

This is not a breaking change: Subprocess['send'] is still defined due to the & ChildProcess line below.

@sindresorhus sindresorhus merged commit acc2b68 into main May 16, 2024
14 checks passed
@sindresorhus sindresorhus deleted the new-ipc branch May 16, 2024 07:17
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.

Promise-based IPC
2 participants