Skip to content
Prev Previous commit
Next Next commit
fix repl error state messaging and close on error
  • Loading branch information
chrisdickinson committed May 12, 2015
commit bdf2b9f3a512f2f4147690cd4aa38041373ed45e
7 changes: 6 additions & 1 deletion lib/internal/repl.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,12 @@ function createRepl(env, attemptPersistentHistory, cb) {

const repl = REPL.start(opts);
if (env.NODE_REPL_HISTORY_FILE && attemptPersistentHistory) {
return setupHistory(repl, env.NODE_REPL_HISTORY_FILE, cb);
return setupHistory(repl, env.NODE_REPL_HISTORY_FILE, function(err) {
if (err) {
repl.close();
}
cb(err);
});
}
repl._historyPrev = _replHistoryMessage;
cb(null, repl);
Expand Down
6 changes: 5 additions & 1 deletion src/node.js
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,11 @@
var cliRepl = Module.requireRepl();
cliRepl.createInternalRepl(process.env, true, function(err, repl) {
if (err) {
console.log('Encountered error with persistent history support.');
console.error('Encountered error with persistent history support.')
console.error('Run with NODE_DEBUG=repl for more information.');
if (/repl/.test(process.env.NODE_DEBUG || '')) {
console.error(err.stack);
}
return cliRepl.createInternalRepl(
process.env, false, function(err, repl) {
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems like an odd style choice, but make jslint didn't complain!

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The linter is set up pretty conservative right now. Not sure it has a rule for odd linebreaks, but it seems fine to me there.

if (err) {
Expand Down