mirror of
https://github.com/zebrajr/node.git
synced 2025-12-07 00:20:38 +01:00
PR-URL: https://github.com/nodejs/node/pull/59964 Reviewed-By: Vinícius Lourenço Claro Cardoso <contact@viniciusl.com.br>
32 lines
796 B
JavaScript
32 lines
796 B
JavaScript
'use strict';
|
|
|
|
const ArrayStream = require('../common/arraystream');
|
|
const repl = require('node:repl');
|
|
const assert = require('node:assert');
|
|
|
|
function startNewREPLServer(replOpts = {}, testingOpts = {}) {
|
|
const input = new ArrayStream();
|
|
const output = new ArrayStream();
|
|
|
|
output.accumulator = '';
|
|
output.write = (data) => (output.accumulator += `${data}`.replaceAll('\r', ''));
|
|
|
|
const replServer = repl.start({
|
|
prompt: '',
|
|
input,
|
|
output,
|
|
terminal: true,
|
|
allowBlockingCompletions: true,
|
|
...replOpts,
|
|
});
|
|
|
|
if (!testingOpts.disableDomainErrorAssert) {
|
|
// Some errors are passed to the domain, but do not callback
|
|
replServer._domain.on('error', assert.ifError);
|
|
}
|
|
|
|
return { replServer, input, output };
|
|
}
|
|
|
|
module.exports = { startNewREPLServer };
|