Skip to content

Commit

Permalink
Remove a few bytes (#74)
Browse files Browse the repository at this point in the history
  • Loading branch information
ehmicky authored Sep 7, 2024
1 parent d722a9f commit 6a888f9
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 4 deletions.
3 changes: 2 additions & 1 deletion source/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,12 @@ export default function nanoSpawn(file, second, third, previous) {
const nodeChildProcess = spawnSubprocess(file, commandArguments, spawnOptions, context);
let subprocess = getResult(nodeChildProcess, spawnOptions, context);
Object.assign(subprocess, {nodeChildProcess});
subprocess = previous ? handlePipe(previous, subprocess) : subprocess;
subprocess = previous ? handlePipe([previous, subprocess]) : subprocess;

const stdout = lineIterator(subprocess, context, 'stdout');
const stderr = lineIterator(subprocess, context, 'stderr');
return Object.assign(subprocess, {
nodeChildProcess,
stdout,
stderr,
[Symbol.asyncIterator]: () => combineAsyncIterators(stdout, stderr),
Expand Down
4 changes: 1 addition & 3 deletions source/pipe.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
import {pipeline} from 'node:stream/promises';

export const handlePipe = (previous, subprocess) => Object.assign(runProcesses([previous, subprocess]), subprocess);

const runProcesses = async subprocesses => {
export const handlePipe = async subprocesses => {
// Ensure both subprocesses have exited before resolving, and that we handle errors from both
const [[from, to]] = await Promise.all([Promise.allSettled(subprocesses), pipeStreams(subprocesses)]);

Expand Down

0 comments on commit 6a888f9

Please sign in to comment.