Commit d0e889c
index.mjs
@@ -156,7 +156,9 @@ export class ProcessPromise extends Promise {
}
pipe(dest) {
- if (typeof dest === 'string') return this.pipe($([dest]))
+ if (typeof dest === 'string') {
+ throw new Error('The pipe() method does not take strings. Forgot $?')
+ }
if (dest instanceof ProcessPromise) {
process.stdin.unpipe(dest.stdin)
this.stdout.pipe(dest.stdin)
test.mjs
@@ -88,7 +88,7 @@ import {strict as assert} from 'assert'
}
{ // Pipes works both ways
- let p = $`read foo; echo "$foo"`.pipe($`cat | wc`).pipe('wc -c')
+ let p = $`read foo; echo "$foo"`.pipe($`cat | wc`).pipe($`wc -c`)
p.stdin.write('hello\n')
assert((await p).stdout === 'hello\n')
}