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
fix: duplication of command name and variable name
Before output the hint, check if defined
the command-named variable as an error
  • Loading branch information
monkingxue committed May 18, 2018
commit 51282ef33eca2ba0c8bdbcaa798ffc9dd0b8dead
3 changes: 2 additions & 1 deletion lib/repl.js
Original file line number Diff line number Diff line change
Expand Up @@ -337,7 +337,8 @@ function REPLServer(prompt,
}
}
} catch (e) {
if (isExitCommand) {
const context = this.useGlobal ? global : this.context;
if (isExitCommand && !context.hasOwnProperty(trimCommand)) {
Copy link
Copy Markdown
Contributor

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?

Copy link
Copy Markdown
Contributor Author

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 ?

Copy link
Copy Markdown
Contributor

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

Copy link
Copy Markdown
Contributor Author

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~

self.outputStream.write('(To exit, press ^D or type .exit)\n');
return self.displayPrompt();
}
Expand Down