Don't call zx, yield commands to it #201
Replies: 2 comments 1 reply
-
Hi 👋 Really interesting project. Nice work 👍 Here is a few points:
let file = 'foo; rm -rf ~'
await $`touch ${file}`
|
Beta Was this translation helpful? Give feedback.
-
hey :) Thanks for taking the time to give some feedbacks. Yield could be used along $ to handle asynchronicity. I'll continue working on it to see if there's other benefit |
Beta Was this translation helpful? Give feedback.
-
Hey :)
Several yers ago, I made something similar to zx: https://github.com/romainPrignon/unshell
Back then, I decided to use generators and yield as a way to call shell commands.
You can use it like this:
There are some advantages to use yield versus regular function calls:
There could be multiple execution engine responding to yield keyword
There's also some drawbacks:
It could be a way to clearly distinct which function yield effect versus pure function
example 1
There is no need to await anything
example 2
Because everything feel synchronous, we loose some control over the promise API
versus
What do you think about using yield in zx script ?
Can it solve some issue ? Is it necessary ?
Is there any other drawback ?
Looking forward to hearing from you :)
Beta Was this translation helpful? Give feedback.
All reactions