forked from nodejs/node
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrepl.js
More file actions
31 lines (24 loc) · 796 Bytes
/
Copy pathrepl.js
File metadata and controls
31 lines (24 loc) · 796 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
'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 };