You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Sometimes you want to use execa.spawn() because you need an object representing the child process while it's running, so you can send signals or listen to events. But then you lose the convenience of a promise-based API (i.e. having a thing you can easily await, which will collect up the stdout/stderr for you).
Suggest adding a method to spawned child objects. This method would return a promise that resolves when the child process exits.
constchild=execa.spawn(...);// do any necessary manual stuff with events/signals etcchild.on(...);// await the final outcomeconst{ stdio, stderr, code }=awaitchild.exited();
(I'm not sure about the name exited though.)
Possible extra feature: the method could take an optional parameter specifying the expected exit code, e.g. .exited(0). If the child process exits with any other code, the promise rejects. If no exit code is specified, the promise will always resolve when the child process exits, no matter how.
The text was updated successfully, but these errors were encountered:
We will actually be deprecating execa.spawn, you will just use execa.
Those changes will allow for this:
constchild=execa(...);// do any necessary manual stuff with events/signals etcchild.on(...);// await the final outcomeconst{ stdio, stderr, code }=awaitchild;
Take a look at those PR's, and if there are additional features or information you would like passed to the promise resolution, comment on the open PR or open a new issue.
Sometimes you want to use
execa.spawn()
because you need an object representing the child process while it's running, so you can send signals or listen to events. But then you lose the convenience of a promise-based API (i.e. having a thing you can easilyawait
, which will collect up the stdout/stderr for you).Suggest adding a method to spawned child objects. This method would return a promise that resolves when the child process exits.
(I'm not sure about the name
exited
though.)Possible extra feature: the method could take an optional parameter specifying the expected exit code, e.g.
.exited(0)
. If the child process exits with any other code, the promise rejects. If no exit code is specified, the promise will always resolve when the child process exits, no matter how.The text was updated successfully, but these errors were encountered: