Skip to content

Add ipcInput option #1068

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 19, 2024
Merged

Add ipcInput option #1068

merged 1 commit into from
May 19, 2024

Conversation

ehmicky
Copy link
Collaborator

@ehmicky ehmicky commented May 18, 2024

This PR adds an ipcInput option, which allows passing almost any value to a subprocess. It sends that value using subprocess.sendMessage() under the hood.

As opposed to argv, environment variables and stdin, it is not limited to strings/Uint8Array. Any value that works with the structured clone algorithm works.

Unlike them though, it only works if the subprocess uses Node.js.

Example:

// main.js
import {execaNode} from 'execa';

const ipcInput = [
	{task: 'lint', ignore: /test\.js/},
	{task: 'copy', files: new Set(['main.js', 'index.js']),
}];
await execaNode({ipcInput})`build.js`;
// build.js
import {getOneMessage} from 'execa';

const ipcInput = await getOneMessage();

@ehmicky ehmicky force-pushed the ipc-input-option branch 3 times, most recently from b0d28b1 to 810b82a Compare May 19, 2024 01:55
@sindresorhus
Copy link
Owner

Conflict

@ehmicky ehmicky force-pushed the ipc-input-option branch from 810b82a to 8f40d37 Compare May 19, 2024 16:40
@ehmicky
Copy link
Collaborator Author

ehmicky commented May 19, 2024

Fixed. 👍

@sindresorhus sindresorhus merged commit 46cae30 into main May 19, 2024
14 checks passed
@sindresorhus sindresorhus deleted the ipc-input-option branch May 19, 2024 22:01
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.

2 participants