Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/lib/repl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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'})
}
}
/**
Expand Down
35 changes: 35 additions & 0 deletions test/unit/lib/repl.unit.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
Loading