From cfc90927c77e5b76168c1ec60b087aebb514d5f2 Mon Sep 17 00:00:00 2001 From: Boris Diakur Date: Thu, 19 Jan 2017 11:21:11 +0100 Subject: [PATCH] Prevent deprecation warning in node 7.4.0 References: https://github.com/tmpvar/repl.history/issues/10 https://github.com/borisdiakur/n_/issues/20 --- index.js | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/index.js b/index.js index cea2c5b..6cfd042 100644 --- a/index.js +++ b/index.js @@ -9,10 +9,16 @@ module.exports = function (repl, file) { } catch (e) {} var fd = fs.openSync(file, 'a'), reval = repl.eval; + var wstream = fs.createWriteStream(file, { + fd: fd + }); + wstream.on('error', function(err) { + throw err; + }); repl.rli.addListener('line', function(code) { if (code && code !== '.history') { - fs.write(fd, code + '\n'); + wstream.write(code + '\n'); } else { repl.rli.historyIndex++; repl.rli.history.pop();