MCPcopy Create free account
hub / github.com/Easy-Editor/EasyEditor / init

Method init

packages/core/src/plugin/plugins.ts:174–198  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

172 }
173
174 async init() {
175 const pluginNames: string[] = []
176 const pluginObj: Record<string, PluginRuntime> = {}
177 this.plugins.forEach(plugin => {
178 pluginNames.push(plugin.name)
179 pluginObj[plugin.name] = plugin
180 })
181
182 // check plugin dependency
183 const { missingTasks, sequence } = sequencify(pluginObj, pluginNames)
184 if (missingTasks.length) {
185 logger.error('plugin dependency missing', missingTasks)
186 return
187 }
188 logger.log('load plugin sequence:', sequence)
189
190 for (const pluginName of sequence) {
191 try {
192 await this.pluginsMap.get(pluginName)!.init()
193 } catch (e) {
194 logger.error(`Failed to init plugin:${pluginName}, it maybe affect those plugins which depend on this.`)
195 logger.error(e)
196 }
197 }
198 }
199
200 /**
201 * destroy all plugins

Callers

nothing calls this directly

Calls 6

sequencifyFunction · 0.90
initMethod · 0.65
getMethod · 0.65
forEachMethod · 0.45
errorMethod · 0.45
logMethod · 0.45

Tested by

no test coverage detected