|
1 | 1 | import { spawn as spawnProcess } from "node:child_process"; |
2 | 2 | import { |
3 | | -all, |
| 3 | + all, |
4 | 4 | createSignal, |
5 | 5 | Err, |
6 | 6 | Ok, |
7 | | - race, |
8 | 7 | type Result, |
9 | 8 | sleep, |
10 | 9 | spawn, |
11 | 10 | withResolvers, |
12 | 11 | } from "effection"; |
13 | 12 | import process from "node:process"; |
14 | 13 | import { once } from "../eventemitter.ts"; |
15 | | -import { box, useReadable } from "../helpers.ts"; |
| 14 | +import { useReadable } from "../helpers.ts"; |
16 | 15 | import type { CreateOSProcess, ExitStatus, Writable } from "./api.ts"; |
17 | 16 | import { ExecError } from "./error.ts"; |
18 | 17 |
|
@@ -53,20 +52,20 @@ export const createPosixProcess: CreateOSProcess = function* createPosixProcess( |
53 | 52 | stderrDone: withResolvers<void>(), |
54 | 53 | }; |
55 | 54 |
|
56 | | - yield* spawn(function*() { |
57 | | - yield* once(childProcess.stdout, 'readable'); |
| 55 | + yield* spawn(function* () { |
| 56 | + yield* once(childProcess.stdout, "readable"); |
58 | 57 | console.log("posix > stdout is readable"); |
59 | 58 | io.stdoutReady.resolve(); |
60 | | - yield* once(childProcess.stdout, 'end'); |
| 59 | + yield* once(childProcess.stdout, "end"); |
61 | 60 | console.log("posix > stdout is done"); |
62 | 61 | io.stdoutDone.resolve(); |
63 | 62 | }); |
64 | 63 |
|
65 | | - yield* spawn(function*() { |
66 | | - yield* once(childProcess.stderr, 'readable'); |
| 64 | + yield* spawn(function* () { |
| 65 | + yield* once(childProcess.stderr, "readable"); |
67 | 66 | console.log("posix > stderr is readable"); |
68 | 67 | io.stderrReady.resolve(); |
69 | | - yield* once(childProcess.stderr, 'end'); |
| 68 | + yield* once(childProcess.stderr, "end"); |
70 | 69 | console.log("posix > err is done"); |
71 | 70 | io.stderrDone.resolve(); |
72 | 71 | }); |
@@ -103,11 +102,15 @@ export const createPosixProcess: CreateOSProcess = function* createPosixProcess( |
103 | 102 | childProcess.stdin.write(data); |
104 | 103 | }, |
105 | 104 | }; |
106 | | - |
| 105 | + |
107 | 106 | yield* spawn(function* () { |
108 | 107 | try { |
109 | 108 | let value = yield* once<ProcessResultValue>(childProcess, "close"); |
110 | | - yield* all([io.stdoutReady.operation, io.stderrReady.operation, sleep(1)]); |
| 109 | + yield* all([ |
| 110 | + io.stdoutReady.operation, |
| 111 | + io.stderrReady.operation, |
| 112 | + sleep(1), |
| 113 | + ]); |
111 | 114 | processResult.resolve(Ok(value)); |
112 | 115 | } finally { |
113 | 116 | try { |
|
0 commit comments