Skip to content

Commit b66760f

Browse files
committed
fix(Shell): History wasn't working when hitting the up and down arrows
1 parent 47d33ea commit b66760f

1 file changed

Lines changed: 3 additions & 8 deletions

File tree

src/adapters/Shell.mjs

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -75,20 +75,15 @@ class Shell extends Adapter {
7575
this.#rl.prompt()
7676
break
7777
}
78+
if (input.length > 0) {
79+
fs.appendFileSync(historyPath, `${input}\n`)
80+
}
7881
const history = fs.readFileSync(historyPath, 'utf-8').split('\n').reverse()
7982
this.#rl.history = history
80-
this.#rl.on('line', line => {
81-
const input = line.trim()
82-
if (input.length === 0) return
83-
fs.appendFile(historyPath, `${input}\n`, err => {
84-
if (err) console.error(err)
85-
})
86-
})
8783
let userId = process.env.HUBOT_SHELL_USER_ID || '1'
8884
if (userId.match(/A\d+z/)) {
8985
userId = parseInt(userId)
9086
}
91-
9287
const userName = process.env.HUBOT_SHELL_USER_NAME || 'Shell'
9388
const user = this.robot.brain.userForId(userId, { name: userName, room: 'Shell' })
9489
await this.receive(new TextMessage(user, input, 'messageId'))

0 commit comments

Comments
 (0)