const Interface = require('readline').Interface;
const REPL = require('repl');
const path = require('path');
+const fs = require('fs');
+const os = require('os');
+const debug = require('util').debuglog('repl');
module.exports = Object.create(REPL);
module.exports.createInternalRepl = createRepl;
}
function setupHistory(repl, historyPath, ready) {
- const fs = require('fs');
+ if (!historyPath) {
+ try {
+ historyPath = path.join(os.homedir(), '.node_repl_history');
+ } catch (err) {
+ repl._writeToOutput('\nError: Could not get the home directory.\n' +
+ 'REPL session history will not be persisted.\n');
+ repl._refreshLine();
+
+ debug(err.stack);
+ repl._historyPrev = _replHistoryMessage;
+ return ready(null, repl);
+ }
+ }
+
var timer = null;
var writing = false;
var pending = false;