MCPcopy
hub / github.com/nestjs/nest / repl

Function repl

packages/core/repl/repl.ts:12–40  ·  view source on GitHub ↗
(
  module: Type | DynamicModule,
  replOptions: ReplOptions = {},
)

Source from the content-addressed store, hash-verified

10import type { ReplOptions } from 'repl';
11
12export async function repl(
13 module: Type | DynamicModule,
14 replOptions: ReplOptions = {},
15) {
16 const app = await NestFactory.createApplicationContext(module, {
17 abortOnError: false,
18 logger: new ReplLogger(),
19 });
20 await app.init();
21
22 const replContext = new ReplContext(app);
23 Logger.log(REPL_INITIALIZED_MESSAGE);
24
25 const _repl = await import('repl');
26 const replServer = _repl.start({
27 prompt: clc.green('> '),
28 ignoreUndefined: true,
29 ...replOptions,
30 });
31 assignToObject(replServer.context, replContext.globalScope);
32
33 defineDefaultCommandsOnRepl(replServer);
34
35 replServer.on('exit', async () => {
36 await app.close();
37 });
38
39 return replServer;
40}

Callers 2

bootstrapFunction · 0.90
repl.spec.tsFile · 0.90

Calls 8

assignToObjectFunction · 0.90
initMethod · 0.65
logMethod · 0.65
onMethod · 0.65
closeMethod · 0.65
startMethod · 0.45

Tested by

no test coverage detected