-
-
Notifications
You must be signed in to change notification settings - Fork 222
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
Small package alternative to Execa #1147
Comments
I already started work on this the other day, but didn't manage to finish yet because of travels. |
This is amazing! 🎉 🎉 🎉 If you need any help, please let me know. Some potential things that could be done to keep things small:
Some features that are useful and can be implemented in not too much code:
Some features that might be left out, from a code size vs usefulness standpoint (unless they can be implemented in just a few lines)?
The following features are harder, as they are quite useful, but harder to implement in less code:
|
First iteration: https://github.com/sindresorhus/nano-spawn It's wildly incomplete. Need to figure out some details before we continue. Constraints:
|
Open question: Should the The former is obviously nicer, but I think I remember some issues with it doing that in |
My thoughts. Please do argue if you disagree with something. You have more experience with subprocesses than me. I value your take on this.
Same as below. This package is for reusable packages, and we should make that clear in the readme.
Nah. This package is mostly for reusable packages where using the array syntax doesn't matter. For scripts,
Maybe?
Already done because the output are just lines.
No. I feel this was a mistake in
Yes, but I would like to simplify it. Would be great to end up with a single option. Maybe one that accepts an iterable or async iterable.
It's the default without opt-out. Not sure we need an option?
Maybe? I think don't it's super important, but could be a nice to have. Let's see how many LOCs the other things take first.
Nah. Would require too much code.
Yes. Could be useful for debugging. Maybe a simpler implementation than in
Nah, can be done in transforms.
Yes. Should not be hard since we only deal with lines of text.
It's the default.
Out of scope.
Not sure. This is mostly useful for scripts, which is not the target. Thoughts?
Nah
It needs some kind of piping, but I would want it to be as simple as possible. Maybe based on async iterables only?
This could be useful in
Nah. You can do all of that from an async iterable, which is already available.
Yes
Could be useful for debugging, but probably requires too much code.
This could be useful.
I'm not even sure why Node.js has this. If you cannot trust the binary you are executing, you already have lost.
Already the default.
A simplified interface for this could be useful.
No
Anti-pattern. Not important. We can defer to
Would require too much code. Let's see how far we get with the other more important things. |
Yes, being a Making that return value iterable also sounds like a good idea. 👍
👍
👍
👍
👍
👍
👍
👍
👍
👍
👍
👍
👍
👍
👍
Yes, that's a good take: only for typical libraries usage, as opposed to scripts, where Execa would be better instead.
Nice idea. Just making everything line-wise.
Yes, that's something that can easily be done by users themselves.
That should actually be fairly small to implement. On the other hand, is it useful enough? The main difference with
Maybe we can do a shortcut implementation. Execa's logic there is actually fairly big.
Yeah, that's a tough one, due to the amount of code that would be required for Windows. And that's a good point that Node.js should just fix some of those issues (even though they have notably not do so for many many years now). We should have a clear understanding (and automated tests) of what is not working on Windows, so we're aware of the limitations.
Having a single option makes sense. I wonder whether iterables would be needed for inputs (as opposed to outputs). For a subprocess, those would most likely be producing string chunks. For sync iterables, users can easily turn it into a single string using They would be useful mostly for incremental/progressive input (programmatic, not coming from an interactive terminal). Technically, users could still do something similar by calling It seems to me the main types of input that users probably need are: none, string, file, inherit.
The main parts are printing: the command line, the output, any error, the success/failure status, the duration. This is very useful indeed. I am wondering how the code for it can be reduced. For example, printing the output might need to be skipped, since it's difficult to do that without changing the code's behavior. 🤔 Also, users can implement most of it themselves by doing some
Wouldn't having access to the output as an iterable be enough? Users can then "map"/"reduce" over it. It's also fairly intuitive. const output = [];
for await (const line of ...) {
output.push(mapLine(line));
}
In most cases, Based on this, it seems like it might important to still keep those separate? That being said, it is true that merging both would simplify the API, because we could define only I.e. maybe One gotcha is that it requires merging iterables, which might increase implementation size. Note: I could be wrong but I think the current implementation here makes each line of
The simplest way to implement piping would be to just do What do you think? Note: after your response, I'll break it down into separate issues in the new repository, to make the conversation clearer. |
👍
Yeah, we can leave it out for now.
I didn't realize it was a big implementation. Maybe not worth it then. It's not essential, just nice to have.
We should really open new issues to restart old conversations. It would especially be useful if we can say that Bun or Deno already does it. They seem more willing to fix things that are missing in Node.js that exists in Bun or Deno.
It's mostly about memory, but yes, I don't think there is a common need.
👍
We can defer it and see the size of the package when we have added the essential stuff.
Indeed. Didn't think about that.
It also exposes
Oh yeah, that is problably wrong.
Yeah, we can always fall back to that. But would be nice to just have a simple way to pipe. Maybe we could take some inspiration from https://bun.sh/docs/api/spawn |
👍 to all of the above! 👏 |
I have added issues in |
Would it make sense for us to create a trimmed down version of Execa? As a separate repository (owned by you like Execa, if you want). With a focus on small package size instead of features. Under 100 lines of code.
Some of the "small package size" alternatives to Execa are not mentioning the key features that users are losing when opting for a smaller alternative (such as security, cross-platform support, debugging, etc.). By creating our own smaller alternative ("yoctoexeca"?), we could better warn users about those trade-offs, so they make an informed decision.
When quickly browsing the code of those smaller alternatives, I could also spot several bugs and issues that are known to us and fixed by Execa. But users might not spot those until they hit those bugs.
This situation is somewhat akin to what happened with Chalk, which led to the creation of Yoctocolors. This would be basically the same idea, but applied to Execa.
What are your thoughts on this @sindresorhus?
The text was updated successfully, but these errors were encountered: