Skip to content

Commit 219790d

Browse files
committed
fix: handle stdout as null
1 parent 00d8d56 commit 219790d

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

src/index.js

+3-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,9 @@ const EE_PROPS = Object.getOwnPropertyNames(
1010
.concat(['kill', 'ref', 'unref'])
1111

1212
const eos = (stream, listener, buffer = []) =>
13-
stream[listener].on('data', data => buffer.push(data)) && buffer
13+
stream[listener]
14+
? stream[listener].on('data', data => buffer.push(data)) && buffer
15+
: buffer
1416

1517
const clean = str => str.trim().replace(/\n$/, '')
1618

test/index.js

+6
Original file line numberDiff line numberDiff line change
@@ -169,3 +169,9 @@ test('child process properties are available', async t => {
169169
t.is(result.exitCode, 0)
170170
;['kill', 'ref', 'unref'].forEach(name => t.truthy(subprocess[name]))
171171
})
172+
173+
test('handle stdout/stderr as inherit', async t => {
174+
const { stdout, stderr } = await $('echo ""', { stdio: 'inherit' })
175+
t.is(stdout, '')
176+
t.is(stderr, '')
177+
})

0 commit comments

Comments
 (0)