Commit cce2624

Anton Medvedev <anton@medv.io>
2021-05-22 17:07:19
Fix a bug
1 parent 45a9e8e
Changed files (2)
index.mjs
@@ -59,7 +59,9 @@ export function $(pieces, ...args) {
   if (typeof $.cwd !== 'undefined') options.cwd = $.cwd
 
   let child = exec($.prefix + cmd, options)
-  process.stdin.pipe(child.stdin)
+  if (process.stdin.isTTY) {
+    process.stdin.pipe(child.stdin)
+  }
 
   let stdout = '', stderr = '', combined = ''
   child.stdout.on('data', data => {
test.mjs
@@ -88,10 +88,10 @@ import {strict as assert} from 'assert'
 }
 
 { // Pipes are working
-  // let {stdout} = await $`echo "hello"`
-  //   .pipe($`awk '{print $1" world"}'`)
-  //   .pipe($`tr '[a-z]' '[A-Z]'`)
-  // assert(stdout === 'HELLO WORLD\n')
+  let {stdout} = await $`echo "hello"`
+    .pipe($`awk '{print $1" world"}'`)
+    .pipe($`tr '[a-z]' '[A-Z]'`)
+  assert(stdout === 'HELLO WORLD\n')
 
   try {
     let w = await $`echo foo`