Skip to content

Commit 5f9c01b

Browse files
cjihrigMylesBorins
authored andcommitted
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: #20972 Fixes: #20965 Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com> Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: John-David Dalton <john.david.dalton@gmail.com>
1 parent ce13797 commit 5f9c01b

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
function defaultEval(code, context, file, cb) {
217217
var err, result, script, wrappedErr;
218-
var isExitCommand = false;
219218
var wrappedCmd = false;
220219
var awaitPromise = false;
221220
var input = code;
222-
var trimmedCommand = 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-
const localContext = self.useGlobal ? global : self.context;
323-
if (isExitCommand && !localContext.hasOwnProperty(trimmedCommand)) {
324-
self.outputStream.write('(To exit, press ^D or type .exit)\n');
325-
return self.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-
const friendlyExitTests = [
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
const errorTests = [
157134
// Uncaught error throws and prints out
158135
{
@@ -763,7 +740,6 @@ const tcpTests = [
763740
const [ socket, replServer ] = await startUnixRepl();
764741

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

0 commit comments

Comments
 (0)