diff --git a/tests/index.test.ts b/tests/index.test.ts index 4fc5d6e..5a0a627 100644 --- a/tests/index.test.ts +++ b/tests/index.test.ts @@ -59,6 +59,7 @@ describe( command: '/bin/echo', args: [message], onExit: (err, exitCode) => { + console.log('huhhh') expect(err).toBeNull(); expect(exitCode).toBe(0); expect(buffer.trim()).toBe(message); diff --git a/wrapper.ts b/wrapper.ts index 5096d38..3b31ff3 100644 --- a/wrapper.ts +++ b/wrapper.ts @@ -74,27 +74,18 @@ export class Pty { this.write = new WriteStream(this.#fd); // catch end events - const handleClose = () => { - console.log('handle close') - this.#fdEnded = true; - }; - - - let ttyStreamEnded = false; const handleEnd = () => { - console.log('handle end') - if (ttyStreamEnded) { + if (this.#fdEnded) { return; } - ttyStreamEnded = true; + this.#fdEnded = true; exitResult.then((result) => { console.log('calling real exit') realExit(result.error, result.code) }); } - this.read.on('close', handleClose); this.read.on('end', handleEnd); // PTYs signal their done-ness with an EIO error. we therefore need to filter them out (as well as