mirror of
https://github.com/nodejs/node.git
synced 2024-11-21 10:59:27 +00:00
9f5977a74d
Do not call `.displayPrompt()` twice after the `eval` callback resulted in an error. (This does not affect the default eval because it doesn’t use the callback if an error occurs.) PR-URL: https://github.com/nodejs/node/pull/38314 Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
24 lines
625 B
JavaScript
24 lines
625 B
JavaScript
'use strict';
|
|
const common = require('../common');
|
|
const assert = require('assert');
|
|
const repl = require('repl');
|
|
const { PassThrough } = require('stream');
|
|
const input = new PassThrough();
|
|
const output = new PassThrough();
|
|
|
|
const r = repl.start({
|
|
input, output,
|
|
eval: common.mustCall((code, context, filename, cb) => {
|
|
r.setPrompt('prompt! ');
|
|
cb(new Error('err'));
|
|
})
|
|
});
|
|
|
|
input.end('foo\n');
|
|
|
|
// The output includes exactly one post-error prompt.
|
|
const out = output.read().toString();
|
|
assert.match(out, /prompt!/);
|
|
assert.doesNotMatch(out, /prompt![\S\s]*prompt!/);
|
|
output.on('data', common.mustNotCall());
|