Skip to content
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
style: fix the code style
  • Loading branch information
monkingxue committed May 18, 2018
commit 17e127267370681b52fd983dcdb2de057c79d6f1
34 changes: 17 additions & 17 deletions lib/repl.js
Original file line number Diff line number Diff line change
Expand Up @@ -214,14 +214,15 @@ function REPLServer(prompt,
}

function defaultEval(code, context, file, cb) {
var err, result, script, wrappedErr, trimCmd;
var isExitCmd = false;
var err, result, script, wrappedErr;
var isExitCommand = false;
var wrappedCmd = false;
var awaitPromise = false;
var input = code;
var trimCommand = code.trim();
Copy link
Copy Markdown
Member

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 :-)


if ((trimCmd = code.trim()) && (trimCmd === 'exit' || trimCmd === 'quit')) {
isExitCmd = true;
if ((trimCommand === 'exit' || trimCommand === 'quit')) {
isExitCommand = true;
}

if (/^\s*\{/.test(code) && /\}\s*$/.test(code)) {
Expand Down Expand Up @@ -336,21 +337,20 @@ function REPLServer(prompt,
}
}
} catch (e) {
if (isExitCmd) {
if (isExitCommand) {
self.outputStream.write('(To exit, press ^D or type .exit)\n');
return self.displayPrompt();
} else {
err = e;
if (err && err.code === 'ERR_SCRIPT_EXECUTION_INTERRUPTED') {
// The stack trace for this case is not very useful anyway.
Copy link
Copy Markdown
Member

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.

Object.defineProperty(err, 'stack', { value: '' });
}
if (process.domain) {
debug('not recoverable, send to domain');
process.domain.emit('error', err);
process.domain.exit();
return;
}
}
err = e;
if (err && err.code === 'ERR_SCRIPT_EXECUTION_INTERRUPTED') {
// The stack trace for this case is not very useful anyway.
Object.defineProperty(err, 'stack', { value: '' });
}
if (process.domain) {
debug('not recoverable, send to domain');
process.domain.emit('error', err);
process.domain.exit();
return;
}
}

Expand Down