Skip to content
Permalink
Browse files

repl: Empty command should be sent to eval function

This fixes a regression introduced in #6171

PR-URL: #11871
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
  • Loading branch information...
Jan Krems authored and jasnell committed Mar 15, 2017
1 parent f0d4237 commit c7b60165a61520941b0e3c18d79b89a88c60d720
Showing with 29 additions and 6 deletions.
  1. +0 −6 lib/repl.js
  2. +29 −0 test/parallel/test-repl-empty.js
@@ -422,12 +422,6 @@ function REPLServer(prompt,
return;
}
}
} else {
// Print a new line when hitting enter.
if (!self.bufferedCommand) {
finish(null);
return;
}
}

const evalCmd = self.bufferedCommand + cmd + '\n';
@@ -0,0 +1,29 @@
'use strict';
const common = require('../common');
const assert = require('assert');
const repl = require('repl');

{
let evalCalledWithExpectedArgs = false;

const options = {
eval: common.mustCall((cmd, context) => {
// Assertions here will not cause the test to exit with an error code
// so set a boolean that is checked in process.on('exit',...) instead.
evalCalledWithExpectedArgs = (cmd === '\n');
})
};

const r = repl.start(options);

try {
// Empty strings should be sent to the repl's eval function
r.write('\n');
} finally {
r.write('.exit\n');
}

process.on('exit', () => {
assert(evalCalledWithExpectedArgs);
});
}

0 comments on commit c7b6016

Please sign in to comment.
You can’t perform that action at this time.