| 20385 | this._debug(message); |
| 20386 | }); |
| 20387 | if (this.options.cwd && !(yield exists(this.options.cwd))) { |
| 20388 | return reject(new Error(`The cwd: ${this.options.cwd} does not exist!`)); |
| 20389 | } |
| 20390 | const fileName = this._getSpawnFileName(); |
| 20391 | const cp = child.spawn(fileName, this._getSpawnArgs(optionsNonNull), this._getSpawnOptions(this.options, fileName)); |
| 20392 | let stdbuffer = ""; |
| 20393 | if (cp.stdout) { |
| 20394 | cp.stdout.on("data", (data) => { |
| 20395 | if (this.options.listeners && this.options.listeners.stdout) { |
| 20396 | this.options.listeners.stdout(data); |
| 20397 | } |
| 20398 | if (!optionsNonNull.silent && optionsNonNull.outStream) { |
| 20399 | optionsNonNull.outStream.write(data); |
| 20400 | } |
| 20401 | stdbuffer = this._processLineBuffer(data, stdbuffer, (line) => { |
| 20402 | if (this.options.listeners && this.options.listeners.stdline) { |
| 20403 | this.options.listeners.stdline(line); |
| 20404 | } |
| 20405 | }); |
| 20406 | }); |
| 20407 | } |
| 20408 | let errbuffer = ""; |
| 20409 | if (cp.stderr) { |
| 20410 | cp.stderr.on("data", (data) => { |
| 20411 | state.processStderr = true; |
| 20412 | if (this.options.listeners && this.options.listeners.stderr) { |
| 20413 | this.options.listeners.stderr(data); |
| 20414 | } |
| 20415 | if (!optionsNonNull.silent && optionsNonNull.errStream && optionsNonNull.outStream) { |
| 20416 | const s = optionsNonNull.failOnStdErr ? optionsNonNull.errStream : optionsNonNull.outStream; |
| 20417 | s.write(data); |
| 20418 | } |
| 20419 | errbuffer = this._processLineBuffer(data, errbuffer, (line) => { |
| 20420 | if (this.options.listeners && this.options.listeners.errline) { |
| 20421 | this.options.listeners.errline(line); |
| 20422 | } |
| 20423 | }); |
| 20424 | }); |
| 20425 | } |
| 20426 | cp.on("error", (err) => { |
| 20427 | state.processError = err.message; |
| 20428 | state.processExited = true; |
| 20429 | state.processClosed = true; |
| 20430 | state.CheckComplete(); |
| 20431 | }); |
| 20432 | cp.on("exit", (code) => { |
| 20433 | state.processExitCode = code; |