-
Notifications
You must be signed in to change notification settings - Fork 78
docs: improve Node REPL dot commands explanation #71
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
base: main
Are you sure you want to change the base?
Changes from 1 commit
0781e7e
d54f9c8
e56c7de
9da1a44
4c02066
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -87,13 +87,12 @@ If you press the `up` arrow key, you will get access to the history of the previ | |
|
|
||
| The REPL has some special commands, all starting with a dot `.`. They are | ||
|
|
||
| - `.help`: shows the dot commands help | ||
| - `.editor`: enables editor mode, to write multiline JavaScript code with ease. Once you are in this mode, enter ctrl-D to run the code you wrote. | ||
| - `.break`: when inputting a multi-line expression, entering the .break command will abort further input. Same as pressing ctrl-C. | ||
| - `.clear`: resets the REPL context to an empty object and clears any multi-line expression currently being input. | ||
| - `.load`: loads a JavaScript file, relative to the current working directory | ||
| - `.save`: saves all you entered in the REPL session to a file (specify the filename) | ||
| - `.exit`: exits the repl (same as pressing ctrl-C two times) | ||
| - `.help`: shows the dot commands help. | ||
| - `.editor`: enters editor mode, to write multiline JavaScript code. | ||
| - `.break` / `.clear`: exits multi-line code like functions. same as pressing ctrl-C. | ||
|
zZMoZz marked this conversation as resolved.
Outdated
|
||
| - `.load`: loads a JavaScript file, relative to the current working directory. | ||
| - `.save`: saves all commands you entered in the session to a file. | ||
|
zZMoZz marked this conversation as resolved.
|
||
| - `.exit`: exits the REPL (same as pressing ctrl-C two times). | ||
|
zZMoZz marked this conversation as resolved.
Outdated
|
||
|
|
||
| The REPL knows when you are typing a multi-line statement without the need to invoke `.editor`. | ||
|
|
||
|
|
@@ -112,6 +111,12 @@ and you press `enter`, the REPL will go to a new line that starts with 3 dots, i | |
|
|
||
| If you type `.break` at the end of a line, the multiline mode will stop and the statement will not be executed. | ||
|
|
||
| `.clear` clear the whole REPL context like restarting the session only in a custom REPL created programmatically: | ||
|
|
||
| ```console | ||
| require('repl').start(); | ||
| ``` | ||
|
|
||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why is this added?
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I tested .clear in the terminal REPL, but it doesn't actually reset the REPL context, variables are stayed there. I tested it also now in a code file, the same thing so I believe I should remove this note.
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I have updated the code recently. Can you check it? |
||
| ### Run REPL from JavaScript file | ||
|
|
||
| We can import the REPL in a JavaScript file using `repl`. | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.