Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
evanw committed Sep 21, 2024
1 parent d5b8baf commit 697faa5
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions lib/deno/mod.ts
Original file line number Diff line number Diff line change
Expand Up @@ -203,11 +203,11 @@ const spawnNew: SpawnFn = (cmd, { args, stdin, stdout, stderr }) => {
stdout,
stderr,
}).spawn()
const writer = child.stdin.getWriter()
const reader = child.stdout.getReader()
const writer = stdin === 'piped' ? child.stdin.getWriter() : null
const reader = stdout === 'piped' ? child.stdout.getReader() : null
return {
write: bytes => writer.write(bytes),
read: () => reader.read().then(x => x.value || null),
write: writer ? bytes => writer.write(bytes) : () => Promise.resolve(),
read: reader ? () => reader.read().then(x => x.value || null) : () => Promise.resolve(null),
close: async () => {
// We can't call "kill()" because it doesn't seem to work. Tests will
// still fail with "A child process was opened during the test, but not
Expand All @@ -223,8 +223,8 @@ const spawnNew: SpawnFn = (cmd, { args, stdin, stdout, stderr }) => {
// we can do.
//
// See this for more info: https://github.com/evanw/esbuild/pull/3611
await writer.close()
await reader.cancel()
if (writer) await writer.close()
if (reader) await reader.cancel()

// Wait for the process to exit. The new "kill()" API doesn't flag the
// process as having exited because processes can technically ignore the
Expand Down

0 comments on commit 697faa5

Please sign in to comment.