const command = Command.make(
"pnpm",
"tsx",
"--env-file",
envFilePath,
mainFile
).pipe(
Command.stdout("inherit"),
Command.stderr("inherit"),
Command.workingDirectory(cwd)
);
const exerciseProcessFork = yield* Effect.fork(
Command.exitCode(command)
);
const keyListenerFork = yield* Effect.fork(
Effect.gen(function* () {
const terminal = yield* Terminal.Terminal;
const mailbox = yield* terminal.readInput;
while (true) {
const { key } = yield* mailbox.take;
if (
(key.name === "c" && (key.ctrl || key.meta)) ||
key.name === "q"
) {
yield* Console.log("Interrupting exercise process");
yield* Fiber.interrupt(exerciseProcessFork);
break;
}
}
}).pipe(Effect.scoped)
);
const command = Command.make(
"pnpm",
"tsx",
"--env-file",
envFilePath,
mainFile
).pipe(
Command.stdout("inherit"),
Command.stderr("inherit"),
Command.workingDirectory(cwd)
);
const exerciseProcessFork = yield* Effect.fork(
Command.exitCode(command)
);
const keyListenerFork = yield* Effect.fork(
Effect.gen(function* () {
const terminal = yield* Terminal.Terminal;
const mailbox = yield* terminal.readInput;
while (true) {
const { key } = yield* mailbox.take;
if (
(key.name === "c" && (key.ctrl || key.meta)) ||
key.name === "q"
) {
yield* Console.log("Interrupting exercise process");
yield* Fiber.interrupt(exerciseProcessFork);
break;
}
}
}).pipe(Effect.scoped)
);