-
-
Notifications
You must be signed in to change notification settings - Fork 538
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We have a place for configuration loaded from environment variables, we should re-use that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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_HISTORY
can be used to customize the file path$TS_NODE_HISTORY_SIZE
can be used to limit the number of saved lines$TS_NODE_HISTORY
is an empty string, history is disabled$TS_NODE_HISTORY_SIZE
is zero, history is disabledCloses #259