Explorar el Código

chore: generate

opencode-agent[bot] hace 3 meses
padre
commit
adccab5970
Se han modificado 2 ficheros con 12 adiciones y 16 borrados
  1. 6 6
      packages/core/src/process.ts
  2. 6 10
      packages/core/test/process/process.test.ts

+ 6 - 6
packages/core/src/process.ts

@@ -144,8 +144,7 @@ export const layer = Layer.effect(
       const timed = options?.timeout
         ? Effect.timeoutOrElse(collect, {
             duration: options.timeout,
-            orElse: () =>
-              Effect.fail(new AppProcessError({ command: description, cause: new Error("Timed out") })),
+            orElse: () => Effect.fail(new AppProcessError({ command: description, cause: new Error("Timed out") })),
           })
         : collect
       const aborted = options?.signal
@@ -158,16 +157,17 @@ export const layer = Layer.effect(
       return yield* aborted.pipe(Effect.catch((cause) => Effect.fail(wrapError(description, cause))))
     })
 
-    const runStream = (command: ChildProcess.Command, options?: RunStreamOptions): Stream.Stream<string, AppProcessError> => {
+    const runStream = (
+      command: ChildProcess.Command,
+      options?: RunStreamOptions,
+    ): Stream.Stream<string, AppProcessError> => {
       const description = describeCommand(command)
       const okExitCodes = options?.okExitCodes
       const built: Stream.Stream<string, AppProcessError | PlatformError> = Stream.unwrap(
         Effect.gen(function* () {
           const handle = yield* spawner.spawn(command)
           const stderrFiber = yield* Effect.forkScoped(
-            collectStream(handle.stderr, options?.maxErrorBytes).pipe(
-              Effect.map((x) => x.buffer.toString("utf8")),
-            ),
+            collectStream(handle.stderr, options?.maxErrorBytes).pipe(Effect.map((x) => x.buffer.toString("utf8"))),
           )
           const source = options?.includeStderr === true ? handle.all : handle.stdout
           const lines = source.pipe(

+ 6 - 10
packages/core/test/process/process.test.ts

@@ -35,7 +35,9 @@ describe("AppProcess", () => {
       "requireSuccess fails on non-zero exit",
       Effect.gen(function* () {
         const svc = yield* AppProcess.Service
-        const exit = yield* Effect.exit(svc.run(cmd("-e", "process.exit(1)")).pipe(Effect.flatMap(AppProcess.requireSuccess)))
+        const exit = yield* Effect.exit(
+          svc.run(cmd("-e", "process.exit(1)")).pipe(Effect.flatMap(AppProcess.requireSuccess)),
+        )
         expect(Exit.isFailure(exit)).toBe(true)
         if (Exit.isFailure(exit)) {
           const reason = exit.cause.reasons[0]
@@ -67,9 +69,7 @@ describe("AppProcess", () => {
         expect(okZero.exitCode).toBe(0)
         const okOne = yield* svc.run(cmd("-e", "process.exit(1)")).pipe(Effect.flatMap(requireZeroOrOne))
         expect(okOne.exitCode).toBe(1)
-        const exit = yield* Effect.exit(
-          svc.run(cmd("-e", "process.exit(2)")).pipe(Effect.flatMap(requireZeroOrOne)),
-        )
+        const exit = yield* Effect.exit(svc.run(cmd("-e", "process.exit(2)")).pipe(Effect.flatMap(requireZeroOrOne)))
         expect(Exit.isFailure(exit)).toBe(true)
         if (Exit.isFailure(exit)) {
           const reason = exit.cause.reasons[0]
@@ -140,9 +140,7 @@ describe("AppProcess", () => {
       Effect.gen(function* () {
         const svc = yield* AppProcess.Service
         const exit = yield* Effect.exit(
-          svc
-            .runStream(cmd("-e", "console.log('a'); process.exit(2)"), { okExitCodes: [0] })
-            .pipe(Stream.runCollect),
+          svc.runStream(cmd("-e", "console.log('a'); process.exit(2)"), { okExitCodes: [0] }).pipe(Stream.runCollect),
         )
         expect(Exit.isFailure(exit)).toBe(true)
         if (Exit.isFailure(exit)) {
@@ -169,9 +167,7 @@ describe("AppProcess", () => {
       "without okExitCodes, never fails on exit code",
       Effect.gen(function* () {
         const svc = yield* AppProcess.Service
-        const result = yield* svc
-          .runStream(cmd("-e", "console.log('only'); process.exit(7)"))
-          .pipe(Stream.runCollect)
+        const result = yield* svc.runStream(cmd("-e", "console.log('only'); process.exit(7)")).pipe(Stream.runCollect)
         expect(Array.from(result)).toEqual(["only"])
       }),
     )