Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 34.2k
repl: add hint as to how to exit#20617
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
Uh oh!
There was an error while loading. Please reload this page.
Conversation
mscdex commented May 9, 2018 • edited
Loading Uh oh!
There was an error while loading. Please reload this page.
edited
Uh oh!
There was an error while loading. Please reload this page.
I think it would be better to at least check that |
mscdex commented May 9, 2018
Also, can you remove the merge commit? |
monkingxue commented May 9, 2018
@mscdex Ok, I will remove the commit. And this is my first commit, so sorry. |
monkingxue commented May 9, 2018
This is the effect changed now. $ ./out/Release/node >exit (To exit, press ^D or type .exit) > quit (To exit, press ^D or type .exit) >exit = 1 1 >exit 1 > quit = 2 2 > quit 2 |
monkingxue commented May 9, 2018 • edited
Loading Uh oh!
There was an error while loading. Please reload this page.
edited
Uh oh!
There was an error while loading. Please reload this page.
When |
Trott commented May 9, 2018
@nodejs/repl |
Trott commented May 9, 2018
Also pinging @princejwesley (who should totally let us know if they want to be added to @nodejs/repl). |
vsemozhetbyt commented May 9, 2018 • edited
Loading Uh oh!
There was an error while loading. Please reload this page.
edited
Uh oh!
There was an error while loading. Please reload this page.
Is this semver-major? Can there be cases when changed output is breaking? |
vsemozhetbyt commented May 9, 2018
princejwesley commented May 9, 2018
Its good to be generic for all defined commands. Its like constcontext=this.useGlobal ? global : this.context;if(context[cmd]===undefined&&this.commands[cmd]&&this[kBufferedCommandSymbol]===''){// emit this.commands[cmd].hint} |
lib/repl.js Outdated
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.
Just a tiny style thing, but could you maybe turn trimCmd = code.trim() into its own line? Also, don’t be shy to use a verbose name like trimCommand/isExitCommand.
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.
Thank you soooo much about your advice! I will modify the code as soon.
lib/repl.js Outdated
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.
I think you don’t really need to add the else{… } here since you return early in the if(){} block anyway.
monkingxue commented May 10, 2018
@princejwesley The |
monkingxue commented May 10, 2018
Hi, this is my first time offering pr to nodejs, so what should I do after commit the changes? Thank you so much~ |
jasnell commented May 10, 2018
@monkingxue ... the process is: a number of us will review the commits and offer feedback as necessary. Once we're relatively sure it's ready, someone with commit access to kick off a CI test run in jenkins at ci.nodejs.org, and if it looks good we'll get it landed. So far you've done everything you need to do :-) |
monkingxue commented May 10, 2018
@jasnell Thank u sooo much~ It is an honor to pr for nodejs ! |
princejwesley commented May 10, 2018 • edited
Loading Uh oh!
There was an error while loading. Please reload this page.
edited
Uh oh!
There was an error while loading. Please reload this page.
@monkingxue Internally commands are not prefixed with I don't think, its a good idea to check in the catch block after executing the code. because Its easy to define exit in such a way that it will throw error. e.g. $node>Object.defineProperty(global,'exit',{get: function(){thrownewError('catch me')}});Object[global]{ ... }>exit Error: catchmeatget(repl:1:65)>I suggest to try something like this. constcontext=this.useGlobal ? global : this.context;if(isExitCommand&&!context.hasOwnProperty(trimCommand)){// emit hint}@nodejs/repl what do you say? |
monkingxue commented May 10, 2018
@princejwesley oh I see! You're right, i will fix the code, thank u suggestion! |
lib/repl.js Outdated
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.
this can be done before executing the code, right?
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.
You mean define the context out of the catch block ?
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.
No. the whole test condition. check this before executing vm.runInContext
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.
ok I got it and I have modified the code, thank u~
BridgeAR left a comment
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.
LGTM with my comments addressed.
lib/repl.js Outdated
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.
Would you be so kind and rename the variable to trimmedCommand? Otherwise I would confuse it with a function :-)
lib/repl.js Outdated
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.
Nit: this is a unrelated change and I think the comment is better the way it was before.
lib/repl.js Outdated
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.
Please remove the extra brackets.
Imitate python repl, when the user enters 'exit' or 'quit', no longer prompt 'Reference Error', but prompts 'To exit, press ^D or type .exit'. If the user defines variables named 'exit' or 'quit' , only the value of the variables are output Fixes: nodejs#19021
Before output the hint, check if defined the command-named variable as an error
BridgeAR commented May 18, 2018
Imitate python repl, when the user enters 'exit' or 'quit', no longer prompt 'Reference Error', but prompts 'To exit, press ^D or type .exit'. If the user defines variables named 'exit' or 'quit' , only the value of the variables are output PR-URL: nodejs#20617Fixes: nodejs#19021 Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: Ruben Bridgewater <[email protected]>
BridgeAR commented May 18, 2018
Landed in 9aa4ec4 @monkingxue congratulations on your first commit to Node.js! 🎉 |
Imitate python repl, when the user enters 'exit' or 'quit', no longer prompt 'Reference Error', but prompts 'To exit, press ^D or type .exit'. If the user defines variables named 'exit' or 'quit' , only the value of the variables are output PR-URL: #20617Fixes: #19021 Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: Ruben Bridgewater <[email protected]>
add friendly tips about how to exit repl.
Fixes: #19021
Checklist
make -j4 test(UNIX), orvcbuild test(Windows) passes