visbug-lib
Version:
<p align="center"> <img src="./assets/visbug.png" width="300" height="300" alt="visbug"> <br> <a href="https://www.npmjs.org/package/visbug"><img src="https://img.shields.io/npm/v/visbug.svg?style=flat" alt="npm latest version number"></a> <a href
30 lines (25 loc) • 615 B
JavaScript
const entries = [
'blank-page.js',
'barrel-roll.js',
'pesticide.js',
'construct.js',
'construct.debug.js',
]
const PluginRegistry = new Map()
entries.forEach(async entry => {
const { commands } = await import(`./plugins/${entry}`)
commands.forEach(command => {
if (PluginRegistry.has(command))
throw new Error('Command already registered')
else
PluginRegistry.set(command, entry)
})
})
const loadPlugin = async command => {
const path = PluginRegistry.get(command)
return (await import(`../plugins/${path}`)).default(command)
}
export {
PluginRegistry,
loadPlugin,
}