MCPcopy
hub / github.com/adonisjs/core / boot

Method boot

providers/repl_provider.ts:102–235  ·  view source on GitHub ↗

* Registering REPL bindings during provider boot * * Adds helper methods to the REPL instance including: * - importDefault: Import default export from modules * - importAll: Import all files from a directory * - make: Create instances using container.make * - load* methods: Quick a

()

Source from the content-addressed store, hash-verified

100 * // REPL now has helper methods available
101 */
102 async boot() {
103 this.app.container.resolving('repl', (repl) => {
104 repl.addMethod(
105 'importDefault',
106 (_, modulePath: string) => {
107 return this.app.importDefault(modulePath)
108 },
109 {
110 description: 'Returns the default export for a module',
111 }
112 )
113
114 repl.addMethod(
115 'importAll',
116 (_, dirPath: string) => {
117 return fsImportAll(this.app.makeURL(dirPath), {
118 ignoreMissingRoot: false,
119 })
120 },
121 {
122 description: 'Import all files from a directory and assign them to a variable',
123 }
124 )
125
126 repl.addMethod(
127 'make',
128 (_, service: any, runtimeValues?: any[]) => {
129 return this.app.container.make(service, runtimeValues)
130 },
131 {
132 description: 'Make class instance using "container.make" method',
133 }
134 )
135
136 repl.addMethod(
137 'loadApp',
138 () => {
139 return resolveBindingForRepl(this.app, repl, 'app')
140 },
141 {
142 description: 'Load "app" service in the REPL context',
143 }
144 )
145
146 repl.addMethod(
147 'loadEncryption',
148 () => {
149 return resolveBindingForRepl(this.app, repl, 'encryption')
150 },
151 {
152 description: 'Load "encryption" service in the REPL context',
153 }
154 )
155
156 repl.addMethod(
157 'loadHash',
158 () => {
159 return resolveBindingForRepl(this.app, repl, 'hash')

Callers

nothing calls this directly

Calls 2

resolveBindingForReplFunction · 0.85
makeMethod · 0.80

Tested by

no test coverage detected