Skip to content

Commit

Permalink
Add promise.subprocess
Browse files Browse the repository at this point in the history
  • Loading branch information
ehmicky committed Aug 18, 2024
1 parent 102d1c1 commit b5323a0
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
1 change: 1 addition & 0 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
8 changes: 8 additions & 0 deletions test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
});

0 comments on commit b5323a0

Please sign in to comment.