From d54858071b85a7178f3b2bbfd13199b18f1b3168 Mon Sep 17 00:00:00 2001 From: Johnny Winn Date: Thu, 21 May 2026 16:20:22 -0600 Subject: [PATCH] fix: pass empty string to rl.write in repl finally block (W-22295448) Co-Authored-By: Claude Sonnet 4.6 --- src/lib/repl.ts | 2 +- test/unit/lib/repl.unit.test.ts | 35 +++++++++++++++++++++++++++++++++ 2 files changed, 36 insertions(+), 1 deletion(-) diff --git a/src/lib/repl.ts b/src/lib/repl.ts index 2dadb905a6..61fa8b28d9 100644 --- a/src/lib/repl.ts +++ b/src/lib/repl.ts @@ -168,7 +168,7 @@ export class HerokuRepl { this.createInterface() this.start() // Force readline to refresh the current line - this.rl.write(null, {ctrl: true, name: 'u'}) + this.rl.write('', {ctrl: true, name: 'u'}) } } /** diff --git a/test/unit/lib/repl.unit.test.ts b/test/unit/lib/repl.unit.test.ts index c1bef82bdb..41016cd189 100644 --- a/test/unit/lib/repl.unit.test.ts +++ b/test/unit/lib/repl.unit.test.ts @@ -172,6 +172,41 @@ describe('HerokuRepl', function () { }) }) + describe('processLine', function () { + it('passes an empty string to rl.write when clearing the line after command execution', async function () { + const writeSpy = stub() + const mockRl = { + close: stub(), + history: [], + off: stub(), + on: stub(), + once: stub(), + prompt: stub(), + setPrompt: stub(), + write: writeSpy, + } + + stub(HerokuRepl.prototype, 'createInterface' as any).callsFake(function (this: any) { + this.rl = mockRl + }) + + config = { + commands: [], + findCommand: stub().returns({flags: {}, id: 'apps:info'}), + root: '/fake/root', + runCommand: stub().resolves(), + } as any + + repl = new HerokuRepl(config) + + await (repl as any).processLine('apps:info') + + const writeCall = writeSpy.args.find((args: any[]) => args[1]?.ctrl === true && args[1]?.name === 'u') + expect(writeCall, 'rl.write should be called for ctrl+u line clear').to.exist + expect(writeCall![0]).to.equal('') + }) + }) + describe('readline interface creation', function () { it('should create readline interface with correct configuration', function () { stub(HerokuRepl.prototype, 'fsExistsSync' as any).returns(false)