Commit ba0b76e

bishil06 <bishil06@naver.com>
2021-05-16 10:44:24
Fix when child stdio is over
ProcessOutput is returned even though the stdio of the child process is not finished.
1 parent 07a2b7b
Changed files (1)
index.mjs
@@ -63,9 +63,10 @@ export function $(pieces, ...args) {
       combined += data
     })
     child.on('exit', code => {
-      (code === 0 ? resolve : reject)(
-        new ProcessOutput({code, stdout, stderr, combined, __from})
-      )
+      const cb = (code === 0 ? resolve : reject)
+      child.on('close', () => {
+        cb(new ProcessOutput({code, stdout, stderr, combined, __from}))
+      })
     })
   })
 }