feat: command history#757
Conversation
Try upgrading to the latest Node 11 if you experience any issues. Closes TypeStrong#259
| repl.history = fs.readFileSync(file, 'utf8').split(os.EOL) | ||
| } | ||
| repl.on('exit', () => { | ||
| fs.writeFileSync(file, repl.history.join(os.EOL)) |
There was a problem hiding this comment.
How does this work with two processes running? It seems like one would just overwrite the other's history?
There was a problem hiding this comment.
Yeah, that's how the node repl works. We could re-read the file in the exit listener and prepend/dedupe the repl.history, but I'd prefer someone else add that in another PR.
|
|
||
| // TODO: Use `repl: REPLServer` when history-related properties are added to @types/node | ||
| export function useHistory (repl: any) { | ||
| repl.historySize = process.env.TS_NODE_HISTORY !== '' |
There was a problem hiding this comment.
We have a place for configuration loaded from environment variables, we should re-use that.
There was a problem hiding this comment.
Maintainer edits are enabled, if you want to help out.
|
Opted for the native implementation using https://nodejs.org/api/repl.html#repl_replserver_setuphistory_historypath_callback in 35d8a0c. |
Try upgrading to the latest Node 11 if you experience any issues. Looks like they had to revert a buggy feature in 11.4.0 (nodejs/node#24804).
Nothing crazy going on here. Just basic history support! 😄
~/.ts_node_history$TS_NODE_HISTORYcan be used to customize the file path$TS_NODE_HISTORY_SIZEcan be used to limit the number of saved lines$TS_NODE_HISTORYis an empty string, history is disabled$TS_NODE_HISTORY_SIZEis zero, history is disabledCloses #259