(inspectorFlags = ['--inspect-brk=0', '--expose-internals'],
scriptContents = '',
scriptFile = _MAINSCRIPT,
logger = console)
| 341 | |
| 342 | class NodeInstance extends EventEmitter { |
| 343 | constructor(inspectorFlags = ['--inspect-brk=0', '--expose-internals'], |
| 344 | scriptContents = '', |
| 345 | scriptFile = _MAINSCRIPT, |
| 346 | logger = console) { |
| 347 | super(); |
| 348 | |
| 349 | this._logger = logger; |
| 350 | this._scriptPath = scriptFile; |
| 351 | this._script = scriptFile ? null : scriptContents; |
| 352 | this._portCallback = null; |
| 353 | this.resetPort(); |
| 354 | this._process = spawnChildProcess(inspectorFlags, scriptContents, |
| 355 | scriptFile); |
| 356 | this._running = true; |
| 357 | this._stderrLineCallback = null; |
| 358 | this._unprocessedStderrLines = []; |
| 359 | |
| 360 | this._process.stdout.on('data', makeBufferingDataCallback( |
| 361 | (line) => { |
| 362 | this.emit('stdout', line); |
| 363 | this._logger.log('[out]', line); |
| 364 | })); |
| 365 | |
| 366 | this._process.stderr.on('data', makeBufferingDataCallback( |
| 367 | (message) => this.onStderrLine(message))); |
| 368 | |
| 369 | this._shutdownPromise = new Promise((resolve) => { |
| 370 | this._process.once('exit', (exitCode, signal) => { |
| 371 | if (signal) { |
| 372 | this._logger.error(`[err] child process crashed, signal ${signal}`); |
| 373 | } |
| 374 | resolve({ exitCode, signal }); |
| 375 | this._running = false; |
| 376 | }); |
| 377 | }); |
| 378 | } |
| 379 | |
| 380 | get pid() { |
| 381 | return this._process.pid; |
nothing calls this directly
no test coverage detected