()
| 230 | }); |
| 231 | |
| 232 | function terminateIfNeeded() { |
| 233 | if (!self.stderrHasEnded || !self.stdoutHasEnded || (self.exitCode == null && self.exitSignal == null)) return; |
| 234 | |
| 235 | let err: PythonShellError; |
| 236 | if (self.exitCode && self.exitCode !== 0) { |
| 237 | if (errorData) { |
| 238 | err = self.parseError(errorData); |
| 239 | } else { |
| 240 | err = new PythonShellError('process exited with code ' + self.exitCode); |
| 241 | } |
| 242 | err = <PythonShellError>extend(err, { |
| 243 | executable: pythonPath, |
| 244 | options: pythonOptions.length ? pythonOptions : null, |
| 245 | script: self.scriptPath, |
| 246 | args: scriptArgs.length ? scriptArgs : null, |
| 247 | exitCode: self.exitCode |
| 248 | }); |
| 249 | // do not emit error if only a callback is used |
| 250 | if (self.listeners('pythonError').length || !self._endCallback) { |
| 251 | self.emit('pythonError', err); |
| 252 | } |
| 253 | } |
| 254 | |
| 255 | self.terminated = true; |
| 256 | self.emit('close'); |
| 257 | self._endCallback && self._endCallback(err, self.exitCode, self.exitSignal); |
| 258 | }; |
| 259 | } |
| 260 | |
| 261 | // built-in formatters |
nothing calls this directly
no test coverage detected