(spawn: ChildProcessSpawner["Service"]["spawn"])
| 221 | * @since 4.0.0 |
| 222 | */ |
| 223 | export const make = (spawn: ChildProcessSpawner["Service"]["spawn"]): ChildProcessSpawner["Service"] => { |
| 224 | const streamString: ChildProcessSpawner["Service"]["streamLines"] = (command, options) => |
| 225 | spawn(command).pipe( |
| 226 | Effect.map((handle) => |
| 227 | Stream.decodeText( |
| 228 | options?.includeStderr === true ? handle.all : handle.stdout |
| 229 | ) |
| 230 | ), |
| 231 | Stream.unwrap |
| 232 | ) |
| 233 | const streamLines: ChildProcessSpawner["Service"]["streamLines"] = (command, options) => |
| 234 | Stream.splitLines(streamString(command, options)) |
| 235 | |
| 236 | return ChildProcessSpawner.of({ |
| 237 | spawn, |
| 238 | exitCode: (command) => Effect.scoped(Effect.flatMap(spawn(command), (handle) => handle.exitCode)), |
| 239 | streamString, |
| 240 | streamLines, |
| 241 | lines: (command, options) => Stream.runCollect(streamLines(command, options)), |
| 242 | string: (command, options) => Stream.mkString(streamString(command, options)) |
| 243 | }) |
| 244 | } |
| 245 | |
| 246 | /** |
| 247 | * Service tag for child process spawning. |
nothing calls this directly
no test coverage detected