diff options
author | Brian White <mscdex@mscdex.net> | 2017-04-30 11:30:16 -0400 |
---|---|---|
committer | Brian White <mscdex@mscdex.net> | 2017-05-02 18:47:16 -0400 |
commit | c20e87a10e6d5cd88b4532d58a2bcf68bcd8745d (patch) | |
tree | 9e41ebff84811e289bc01f11aba80dbb79dded11 /lib/internal/repl.js | |
parent | dc3bbb45a7a17c97dbe2260e49baf725c53a7a79 (diff) | |
download | android-node-v8-c20e87a10e6d5cd88b4532d58a2bcf68bcd8745d.tar.gz android-node-v8-c20e87a10e6d5cd88b4532d58a2bcf68bcd8745d.tar.bz2 android-node-v8-c20e87a10e6d5cd88b4532d58a2bcf68bcd8745d.zip |
repl: fix /dev/null history file regression
This fixes a regression from 83887f35fa where ftruncate() fails on
a file symlinked to /dev/null.
PR-URL: https://github.com/nodejs/node/pull/12762
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Jeremiah Senkpiel <fishrock123@rocketmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Bartosz Sosnowski <bartosz@janeasystems.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Diffstat (limited to 'lib/internal/repl.js')
-rw-r--r-- | lib/internal/repl.js | 25 |
1 files changed, 9 insertions, 16 deletions
diff --git a/lib/internal/repl.js b/lib/internal/repl.js index c98fd00e35..4c27fa2746 100644 --- a/lib/internal/repl.js +++ b/lib/internal/repl.js @@ -172,25 +172,18 @@ function setupHistory(repl, historyPath, oldHistoryPath, ready) { return ready(err); } fs.ftruncate(hnd, 0, (err) => { - return onftruncate(err, hnd); + repl._historyHandle = hnd; + repl.on('line', online); + + // reading the file data out erases it + repl.once('flushHistory', function() { + repl.resume(); + ready(null, repl); + }); + flushHistory(); }); } - function onftruncate(err, hnd) { - if (err) { - return ready(err); - } - repl._historyHandle = hnd; - repl.on('line', online); - - // reading the file data out erases it - repl.once('flushHistory', function() { - repl.resume(); - ready(null, repl); - }); - flushHistory(); - } - // ------ history listeners ------ function online() { repl._flushing = true; |