(prompt,
stream,
eval_,
useGlobal,
ignoreUndefined,
replMode)
| 278 | |
| 279 | class REPLServer extends Interface { |
| 280 | constructor(prompt, |
| 281 | stream, |
| 282 | eval_, |
| 283 | useGlobal, |
| 284 | ignoreUndefined, |
| 285 | replMode) { |
| 286 | let options; |
| 287 | if (prompt !== null && typeof prompt === 'object') { |
| 288 | // An options object was given. |
| 289 | options = { ...prompt }; |
| 290 | stream = options.stream || options.socket; |
| 291 | eval_ = options.eval; |
| 292 | useGlobal = options.useGlobal; |
| 293 | ignoreUndefined = options.ignoreUndefined; |
| 294 | prompt = options.prompt; |
| 295 | replMode = options.replMode; |
| 296 | } else { |
| 297 | options = {}; |
| 298 | } |
| 299 | |
| 300 | if (!options.input && !options.output) { |
| 301 | // Legacy API, passing a 'stream'/'socket' option. |
| 302 | // Use stdin and stdout as the default streams if none were given. |
| 303 | stream ||= process; |
| 304 | |
| 305 | // We're given a duplex readable/writable Stream, like a `net.Socket` |
| 306 | // or a custom object with 2 streams, or the `process` object. |
| 307 | options.input = stream.stdin || stream; |
| 308 | options.output = stream.stdout || stream; |
| 309 | } |
| 310 | |
| 311 | if (options.terminal === undefined) { |
| 312 | options.terminal = options.output.isTTY; |
| 313 | } |
| 314 | options.terminal = !!options.terminal; |
| 315 | |
| 316 | if (options.terminal && options.useColors === undefined) { |
| 317 | // If possible, check if stdout supports colors or not. |
| 318 | options.useColors = shouldColorize(options.output); |
| 319 | } |
| 320 | |
| 321 | const preview = options.terminal && |
| 322 | (options.preview !== undefined ? !!options.preview : !eval_); |
| 323 | |
| 324 | super({ |
| 325 | input: options.input, |
| 326 | output: options.output, |
| 327 | completer: options.completer || completer, |
| 328 | terminal: options.terminal, |
| 329 | historySize: options.historySize, |
| 330 | prompt, |
| 331 | }); |
| 332 | |
| 333 | ObjectDefineProperty(this, 'inputStream', { |
| 334 | __proto__: null, |
| 335 | get: pendingDeprecation ? |
| 336 | deprecate(() => this.input, |
| 337 | 'repl.inputStream and repl.outputStream are deprecated. ' + |
nothing calls this directly
no test coverage detected