Commit 49b438a
Changed files (2)
src
test
src/util.ts
@@ -99,20 +99,13 @@ export function exitCodeInfo(exitCode: number | null): string | undefined {
}[exitCode || -1]
}
-export function stdin() {
- try {
- if (process.env.FX_ASYNC_STDIN == 'true') throw 'yes'
- return fs.readFileSync(process.stdin.fd).toString()
- } catch (err) {
- return (async function () {
- let buf = ''
- process.stdin.setEncoding('utf8')
- for await (const chunk of process.stdin) {
- buf += chunk
- }
- return buf
- })()
+export async function stdin() {
+ let buf = ''
+ process.stdin.setEncoding('utf8')
+ for await (const chunk of process.stdin) {
+ buf += chunk
}
+ return buf
}
export type Duration = number | `${number}s` | `${number}ms`
test/cli.test.js
@@ -126,13 +126,7 @@ test('eval works', async () => {
})
test('eval works with stdin', async () => {
- let { stdout } =
- await $`printf "Hello world" | node build/cli.js --eval='echo(stdin)'`
- assert.is(stdout, 'Hello world\n')
-})
-
-test('eval works with async stdin', async () => {
- let p = $`(printf foo; sleep 0.1; printf bar) | FX_ASYNC_STDIN=true node build/cli.js --eval 'echo(await stdin)'`
+ let p = $`(printf foo; sleep 0.1; printf bar) | node build/cli.js --eval 'echo(await stdin)'`
assert.is((await p).stdout, 'foobar\n')
})