Skip to content

Commit

Permalink
Don't use deprecated REPLServer.rli property.
Browse files Browse the repository at this point in the history
This property is deprecated since Node.js 12.
nodejs/node#26260
  • Loading branch information
klaussner committed Jan 29, 2020
1 parent daa8e98 commit 0bdf790
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions packages/shell-server/shell-server.js
Original file line number Diff line number Diff line change
Expand Up @@ -314,28 +314,28 @@ class Server {
}

// This function allows a persistent history of shell commands to be saved
// to and loaded from .meteor/local/shell-history.
// to and loaded from .meteor/local/shell/history.
initializeHistory() {
const rli = this.repl.rli;
const repl = this.repl;
const historyFile = getHistoryFile(this.shellDir);
let historyFd = openSync(historyFile, "a+");
const historyLines = readFileSync(historyFile, "utf8").split("\n");
const seenLines = Object.create(null);

if (! rli.history) {
rli.history = [];
rli.historyIndex = -1;
if (! repl.history) {
repl.history = [];
repl.historyIndex = -1;
}

while (rli.history && historyLines.length > 0) {
while (repl.history && historyLines.length > 0) {
const line = historyLines.pop();
if (line && /\S/.test(line) && ! seenLines[line]) {
rli.history.push(line);
repl.history.push(line);
seenLines[line] = true;
}
}

rli.addListener("line", function(line) {
repl.addListener("line", function(line) {
if (historyFd >= 0 && /\S/.test(line)) {
writeSync(historyFd, line + "\n");
}
Expand Down

0 comments on commit 0bdf790

Please sign in to comment.