Open eush77 opened 9 years ago
just gave you the commit bit since I don't have time to maintain this project at the moment and you seem eager.
I have had a look into how the node repl handles history.
The file format is very similar to the format used by repl.history but the entries are stored in the opposite order. repl.history puts newest lines at the bottom of the file where as node puts newest lines first.
The meaty code is: https://github.com/nodejs/node/blob/master/lib/internal/repl.js#L72-L234
On line 211:
function flushHistory() {
timer = null;
if (writing) {
pending = true;
return;
}
writing = true;
const historyData = repl.history.join(os.EOL);
fs.write(repl._historyHandle, historyData, 0, 'utf8', onwritten);
}
Nothing any fancier than completely rewriting the file every time something happens.
It wouldn't be too hard to do the same for repl.history I do think.
repl.history's file format is not compatible with Node's history file format. https://github.com/nodejs/io.js/pull/1513
After pointing NODE_REPL_HISTORY_FILE to my old history file I get the following error:
It would be nice to have one file format be used both from native repls and repls built on top of this module.