-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
An easy way to specify stdin #720
Comments
Nice idea |
Not quite familiar with zx or js, but I have played a bit with both as well as other languages. I think this is a good idea, and could cut down on cumbersome-ness. |
We're planning to introduce smth like const input = '{"name": "foo"}'
const name = await $({input})`jq -r .name` // foo
const stdin = fs.createReadStream(path.join(fixtures, 'foo.json'))
const data = await $({stdin})`jq -r .data` // foo
const p = $`echo "5\\n3\\n1\\n4\\n2"`
const sorted = $({input: p})`sort` // 1\n2\n3\n4\n5 |
antongolub
added a commit
to antongolub/zx
that referenced
this issue
Mar 17, 2024
antonmedv
pushed a commit
that referenced
this issue
Mar 17, 2024
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Right now, there are (at least?) two ways to specify stdin:
Via pipes:
$`echo ${input} | command`
This works, but at least on GitHub runners it can suffer from random SIGPIPE (exit code 141) failures that are not reproducible locally. No idea why.
Via
.stdin
:This requires giving a name to the command itself, and is a bit cumbersome to use.
I propose pushing the latter pattern into a function or a method, eg. something like
or perhaps
The text was updated successfully, but these errors were encountered: