MCPcopy Create free account
hub / github.com/Dart-Code/Dart-Code / createProcess

Function createProcess

src/shared/services/stdio_service.ts:32–57  ·  view source on GitHub ↗
(workingDirectory: string | undefined, binPath: string, args: string[], envOverrides: { envOverrides?: Record<string, string | undefined>, toolEnv?: Record<string, string | undefined> })

Source from the content-addressed store, hash-verified

30 }
31
32 protected createProcess(workingDirectory: string | undefined, binPath: string, args: string[], envOverrides: { envOverrides?: Record<string, string | undefined>, toolEnv?: Record<string, string | undefined> }) {
33 this.logTraffic(`Spawning ${binPath} with args ${JSON.stringify(args)}`);
34 this.description = binPath;
35 if (workingDirectory)
36 this.logTraffic(`.. in ${workingDirectory}`);
37 if (envOverrides.envOverrides || envOverrides.toolEnv)
38 this.logTraffic(`.. with ${JSON.stringify(envOverrides)}`);
39
40 const env = Object.assign({}, envOverrides.toolEnv, envOverrides.envOverrides);
41 try {
42 this.process = safeSpawn(workingDirectory, binPath, args, env);
43 } catch (e) {
44 this.logger.error(`Failed to spawn process! ${e}`);
45 this.handleError(e);
46 this.handleExit(null, null);
47 }
48
49 if (this.process) {
50 this.logTraffic(` PID: ${process.pid}`);
51
52 this.process.stdout.on("data", (data: Buffer | string) => this.handleStdOut(data));
53 this.process.stderr.on("data", (data: Buffer | string) => this.handleStdErr(data));
54 this.process.on("exit", (code, signal) => this.handleExit(code, signal));
55 this.process.on("error", (error) => this.handleError(error));
56 }
57 }
58
59 /// Flutter may send only \r as a line terminator for improved terminal output
60 /// but we should always treat this as a standard newline (eg. terminating a message)

Callers

nothing calls this directly

Calls 6

safeSpawnFunction · 0.90
onMethod · 0.80
errorMethod · 0.65
logTrafficMethod · 0.45
handleErrorMethod · 0.45
handleExitMethod · 0.45

Tested by

no test coverage detected