Skip to content
This repository has been archived by the owner on Apr 22, 2023. It is now read-only.

Commit

Permalink
ignore undefined messages in the debugger repl
Browse files Browse the repository at this point in the history
fixes #1995
  • Loading branch information
indutny authored and ry committed Nov 2, 2011
1 parent c8646e0 commit 9ad27f7
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 4 deletions.
5 changes: 4 additions & 1 deletion doc/api/repl.markdown
Expand Up @@ -27,7 +27,7 @@ For example, you could add this to your bashrc file:
alias node="env NODE_NO_READLINE=1 rlwrap node"


### repl.start(prompt='> ', stream=process.stdin, eval=eval, useGlobal=false)
### repl.start(prompt='> ', stream=process.stdin, eval=eval, useGlobal=false, ignoreUndefined=false)

Starts a REPL with `prompt` as the prompt and `stream` for all I/O. `prompt`
is optional and defaults to `> `. `stream` is optional and defaults to
Expand All @@ -36,6 +36,9 @@ is optional and defaults to `> `. `stream` is optional and defaults to
If `useGlobal` is set to true, then the repl will use the global object,
instead of running scripts in a separate context.

If `ignoreUndefined` is set to true, then the repl will not output return value
of command if it's `undefined`.

You can use your own `eval` function if it has following signature:

function eval(cmd, callback) {
Expand Down
2 changes: 1 addition & 1 deletion lib/_debugger.js
Expand Up @@ -724,7 +724,7 @@ function Interface(stdin, stdout, args) {
// Two eval modes are available: controlEval and debugEval
// But controlEval is used by default
this.repl = new repl.REPLServer('debug> ', streams,
this.controlEval.bind(this));
this.controlEval.bind(this), false, true);

// Kill child process when repl closed or main process is dead
this.repl.rli.addListener('close', function() {
Expand Down
4 changes: 2 additions & 2 deletions lib/repl.js
Expand Up @@ -68,7 +68,7 @@ module.paths = require('module')._nodeModulePaths(module.filename);
exports.writer = util.inspect;


function REPLServer(prompt, stream, eval, useGlobal) {
function REPLServer(prompt, stream, eval, useGlobal, ignoreUndefined) {
var self = this;

self.useGlobal = useGlobal;
Expand Down Expand Up @@ -224,7 +224,7 @@ function REPLServer(prompt, stream, eval, useGlobal) {
self.bufferedCommand = '';

// If we got any output - print it (if no error)
if (!e) {
if (!e && (!ignoreUndefined || ret !== undefined)) {
self.context._ = ret;
self.outputStream.write(exports.writer(ret) + '\n');
}
Expand Down

0 comments on commit 9ad27f7

Please sign in to comment.