Skip to content

Commit 4dbfb09

Browse files
committed
Revert "repl: add friendly tips about how to exit repl"
This reverts commit 9aa4ec4. This commit in question introduced a regression in repl.eval(), as the context argument is no longer passed to runInContext(). PR-URL: #20972Fixes: #20965 Reviewed-By: Ben Noordhuis <[email protected]> Reviewed-By: Benjamin Gruenbaum <[email protected]> Reviewed-By: Trivikram Kamat <[email protected]> Reviewed-By: Ruben Bridgewater <[email protected]> Reviewed-By: John-David Dalton <[email protected]>
1 parent 35cf008 commit 4dbfb09

File tree

2 files changed

+4
-38
lines changed

2 files changed

+4
-38
lines changed

‎lib/repl.js‎

Lines changed: 4 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -215,15 +215,9 @@ function REPLServer(prompt,
215215

216216
functiondefaultEval(code,context,file,cb){
217217
varerr,result,script,wrappedErr;
218-
varisExitCommand=false;
219218
varwrappedCmd=false;
220219
varawaitPromise=false;
221220
varinput=code;
222-
vartrimmedCommand=code.trim();
223-
224-
if(trimmedCommand==='exit'||trimmedCommand==='quit'){
225-
isExitCommand=true;
226-
}
227221

228222
if(/^\s*\{/.test(code)&&/\}\s*$/.test(code)){
229223
// It's confusing for `{a : 1 }` to be interpreted as a block
@@ -319,16 +313,10 @@ function REPLServer(prompt,
319313
breakOnSigint: self.breakEvalOnSigint
320314
};
321315

322-
constlocalContext=self.useGlobal ? global : self.context;
323-
if(isExitCommand&&!localContext.hasOwnProperty(trimmedCommand)){
324-
self.outputStream.write('(To exit, press ^D or type .exit)\n');
325-
returnself.displayPrompt();
326-
}
327-
328316
if(self.useGlobal){
329317
result=script.runInThisContext(scriptOptions);
330318
}else{
331-
result=script.runInContext(localContext,scriptOptions);
319+
result=script.runInContext(context,scriptOptions);
332320
}
333321
}finally{
334322
if(self.breakEvalOnSigint){
@@ -344,10 +332,12 @@ function REPLServer(prompt,
344332
}
345333
}catch(e){
346334
err=e;
335+
347336
if(err&&err.code==='ERR_SCRIPT_EXECUTION_INTERRUPTED'){
348-
// The stack trace for this case is not very useful anyway.
337+
// The stack trace for this case is not very useful anyway.
349338
Object.defineProperty(err,'stack',{value: ''});
350339
}
340+
351341
if(process.domain){
352342
debug('not recoverable, send to domain');
353343
process.domain.emit('error',err);

‎test/parallel/test-repl.js‎

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -130,29 +130,6 @@ const strictModeTests = [
130130
}
131131
];
132132

133-
constfriendlyExitTests=[
134-
{
135-
send: 'exit',
136-
expect: '(To exit, press ^D or type .exit)'
137-
},
138-
{
139-
send: 'quit',
140-
expect: '(To exit, press ^D or type .exit)'
141-
},
142-
{
143-
send: 'quit = 1',
144-
expect: '1'
145-
},
146-
{
147-
send: 'quit',
148-
expect: '1'
149-
},
150-
{
151-
send: 'exit',
152-
expect: '(To exit, press ^D or type .exit)'
153-
},
154-
];
155-
156133
consterrorTests=[
157134
// Uncaught error throws and prints out
158135
{
@@ -763,7 +740,6 @@ const tcpTests = [
763740
const[socket,replServer]=awaitstartUnixRepl();
764741

765742
awaitrunReplTests(socket,prompt_unix,unixTests);
766-
awaitrunReplTests(socket,prompt_unix,friendlyExitTests);
767743
awaitrunReplTests(socket,prompt_unix,errorTests);
768744
replServer.replMode=repl.REPL_MODE_STRICT;
769745
awaitrunReplTests(socket,prompt_unix,strictModeTests);

0 commit comments

Comments
(0)