(workingDirectory: string | undefined, binPath: string, args: string[], envOverrides: { envOverrides?: Record<string, string | undefined>, toolEnv?: Record<string, string | undefined> })
| 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) |
nothing calls this directly
no test coverage detected