Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nodejs/node.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChris Dickinson <christopher.s.dickinson@gmail.com>2015-05-04 18:56:14 +0300
committerChris Dickinson <christopher.s.dickinson@gmail.com>2015-05-04 20:45:14 +0300
commitca219b00d163254f866e3287f690845d437b993a (patch)
tree8736bb24c5e1bc786fe3a84cb1d1a5fc81e82fe8
parent051d482b151cc15b8273d705ec57209d0fa1db2a (diff)
repl: fix for a+ fd clearing the file on read
The second step of augmenting the internal REPL with persistent history was to re-open the history file with a 'w' handle. This truncated the file. If a user did not enter a new line before closing the REPL, their history would be deleted. PR-URL: https://github.com/iojs/io.js/pull/1605 Reviewed-By: Roman Reiss <me@silverwind.io>
-rw-r--r--lib/internal/repl.js9
-rw-r--r--src/node.js3
2 files changed, 9 insertions, 3 deletions
diff --git a/lib/internal/repl.js b/lib/internal/repl.js
index 65c3f77ed6a..902e81f4955 100644
--- a/lib/internal/repl.js
+++ b/lib/internal/repl.js
@@ -107,8 +107,13 @@ function setupHistory(repl, historyPath, ready) {
}
repl._historyHandle = hnd;
repl.on('line', online);
- repl.resume();
- return ready(null, repl);
+
+ // reading the file data out erases it
+ repl.once('flushHistory', function() {
+ repl.resume();
+ ready(null, repl);
+ });
+ flushHistory();
}
// ------ history listeners ------
diff --git a/src/node.js b/src/node.js
index 2d6ce45a928..bd8ef5b04ef 100644
--- a/src/node.js
+++ b/src/node.js
@@ -130,7 +130,8 @@
// If -i or --interactive were passed, or stdin is a TTY.
if (process._forceRepl || NativeModule.require('tty').isatty(0)) {
// REPL
- Module.requireRepl().createInternalRepl(process.env, function(err, repl) {
+ var cliRepl = Module.requireRepl();
+ cliRepl.createInternalRepl(process.env, function(err, repl) {
if (err) {
throw err;
}