Skip to content
This repository has been archived by the owner on Jun 8, 2021. It is now read-only.

Commit

Permalink
fix(repl): create history file if doesn't exists (#58)
Browse files Browse the repository at this point in the history
  • Loading branch information
RomainLanz authored and thetutlage committed Sep 14, 2017
1 parent 67ca54d commit 3fb526b
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions src/Commands/Repl/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,12 +55,13 @@ class Repl extends Command {
_readHistoryFile (repl) {
try {
fs.statSync(historyFile)
repl.rli.history = fs.readFileSync(historyFile, 'utf-8').split('\n').reverse()
repl.rli.history.shift()
repl.rli.historyIndex = -1
} catch (error) {
console.error(error)
fs.closeSync(fs.openSync(historyFile, 'w'))
}

repl.rli.history = fs.readFileSync(historyFile, 'utf-8').split('\n').reverse()
repl.rli.history.shift()
repl.rli.historyIndex = -1
}

/**
Expand Down

0 comments on commit 3fb526b

Please sign in to comment.