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

Method spawn

packages/platform/node-shared/src/internal/proxyProcess.ts:270–304  ·  view source on GitHub ↗

* Sends a spawn request, at most once. A proxy process that is no longer * ready to take spawns, or whose credentials are out of date, fails the * spawn without sending it, so every command it holds has been sent.

(
    command: string,
    args: ReadonlyArray<string>,
    options: NodeChildProcess.SpawnOptions,
    halfOpen: ReadonlyArray<number>
  )

Source from the content-addressed store, hash-verified

268 * spawn without sending it, so every command it holds has been sent.
269 */
270 spawn(
271 command: string,
272 args: ReadonlyArray<string>,
273 options: NodeChildProcess.SpawnOptions,
274 halfOpen: ReadonlyArray<number>
275 ): ProxiedProcess {
276 if (!this.ready || this.exited || this.retired || this.credentials !== credentials()) {
277 const refused = new ProxiedProcess(noOwner, 0, [])
278 const error = new Error("The proxy process stopped taking spawns before the command was sent to it")
279 globalThis.process.nextTick(() => refused.onError(error))
280 return refused
281 }
282 const id = this.nextId
283 this.nextId = (this.nextId + 1) % 0x1_0000_0000
284 const stdio = (options.stdio as ReadonlyArray<NodeChildProcess.IOType | undefined>).map((mode) =>
285 mode === undefined || mode === "overlapped" ? "pipe" : mode
286 )
287 const child = new ProxiedProcess(this, id, stdio.map((mode) => mode === "pipe"), halfOpen)
288 this.commands.set(id, child)
289 this.startTimer(id)
290 this.send({
291 id,
292 command,
293 args,
294 options: {
295 cwd: options.cwd ?? globalThis.process.cwd(),
296 env: options.env ?? globalThis.process.env,
297 detached: options.detached,
298 shell: options.shell,
299 windowsHide: options.windowsHide,
300 stdio
301 }
302 })
303 return child
304 }
305
306 ref(): void {
307 this.refs++

Callers 15

runFunction · 0.80
PostProcess.tsFile · 0.80
WorktreesClass · 0.80
spawnDirectFunction · 0.80
spawnFunction · 0.80
constructorMethod · 0.80
makeFunction · 0.80
spawnPeerFunction · 0.80
spawnFunction · 0.80
Worker.test.tsFile · 0.80

Calls 6

onErrorMethod · 0.95
startTimerMethod · 0.95
sendMethod · 0.95
credentialsFunction · 0.85
setMethod · 0.65
mapMethod · 0.45

Tested by

no test coverage detected