diff --git a/index.js b/index.js index fd7a5b0..c837ad3 100644 --- a/index.js +++ b/index.js @@ -26,6 +26,7 @@ export default function nanoSpawn(command, arguments_ = [], {signal, timeout, na const stderrLines = lineIterator(subprocess.stderr); return Object.assign(promise, { + subprocess, [Symbol.asyncIterator]: () => combineAsyncIterables(stdoutLines, stderrLines), stdout: stdoutLines, stderr: stderrLines, diff --git a/test.js b/test.js index 73d8c53..48fa9ba 100644 --- a/test.js +++ b/test.js @@ -55,3 +55,11 @@ test('returns a promise', async t => { t.true(result instanceof Promise); await result; }); + +test('promise.subprocess is set', async t => { + const promise = nanoSpawn('node'); + promise.subprocess.kill(); + + const {exitCode} = await promise; + t.is(exitCode, null); +});