MCPcopy Create free account
hub / github.com/Effect-TS/effect / runOpenSelect

Function runOpenSelect

packages/platform/node-shared/test/NodeTerminal.test.ts:63–91  ·  view source on GitHub ↗
(input: string, customQuit = false)

Source from the content-addressed store, hash-verified

61 })
62
63const runOpenSelect = (input: string, customQuit = false) =>
64 Effect.callback<{ stdout: string; stderr: string }>((resume) => {
65 const child = spawn(process.execPath, [fixture, customQuit ? "select-custom-quit" : "select"])
66 let stdout = ""
67 let stderr = ""
68 let submitted = false
69 child.stdout.setEncoding("utf8")
70 child.stderr.setEncoding("utf8")
71 child.stdout.on("data", (data) => {
72 stdout += data
73 // Wait for bare Esc to be decoded before submitting the custom prompt.
74 if (customQuit && !submitted && stdout.includes("\x07")) {
75 submitted = true
76 child.stdin.write("\r")
77 }
78 })
79 child.stderr.on("data", (data) => {
80 stderr += data
81 if (stderr.includes("RESULT ")) {
82 child.stdin.end()
83 }
84 })
85 child.on("error", (error) => resume(Effect.die(error)))
86 child.on("close", (code) => {
87 resume(code === 0 ? Effect.succeed({ stdout, stderr }) : Effect.die(new Error(stderr)))
88 })
89 child.stdin.write(input)
90 return Effect.sync(() => child.kill())
91 })
92
93// spawnSync blocks the Vitest worker; concurrent tests share a running timeout
94// while waiting for other fixture processes to finish.

Callers 1

Calls 8

onMethod · 0.65
writeMethod · 0.65
endMethod · 0.65
killMethod · 0.65
spawnFunction · 0.50
resumeFunction · 0.50
succeedMethod · 0.45
syncMethod · 0.45

Tested by

no test coverage detected