minor with plugins
This commit is contained in:
@@ -107,15 +107,17 @@ const settingsController = {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// load custom plugins
|
||||||
const plugins_path = path.resolve(process.env.cwd || '', 'plugins')
|
const plugins_path = path.resolve(process.env.cwd || '', 'plugins')
|
||||||
if (fs.existsSync(plugins_path)) {
|
if (fs.existsSync(plugins_path)) {
|
||||||
const notifier = require('../../notifier')
|
const notifier = require('../../notifier')
|
||||||
const pluginsFile = fs.readdirSync(plugins_path).filter(e => path.extname(e).toLowerCase() === '.js')
|
const pluginsFile = fs.readdirSync(plugins_path).filter(e => path.extname(e).toLowerCase() === '.js')
|
||||||
pluginsFile.forEach( pluginFile => {
|
pluginsFile.forEach( pluginFile => {
|
||||||
log.info(`Loading plugin ${pluginFile}`)
|
|
||||||
try {
|
try {
|
||||||
const plugin = require(path.resolve(plugins_path, pluginFile))
|
const plugin = require(path.resolve(plugins_path, pluginFile))
|
||||||
|
if (typeof plugin.load !== 'function') return
|
||||||
plugin.load({ settings: settingsController.settings })
|
plugin.load({ settings: settingsController.settings })
|
||||||
|
log.info(`Plugin ${pluginFile} loaded!`)
|
||||||
if (typeof plugin.onEventCreate === 'function') {
|
if (typeof plugin.onEventCreate === 'function') {
|
||||||
notifier.emitter.on('Create', plugin.onEventCreate)
|
notifier.emitter.on('Create', plugin.onEventCreate)
|
||||||
}
|
}
|
||||||
@@ -126,7 +128,7 @@ const settingsController = {
|
|||||||
notifier.emitter.on('Update', plugin.onEventUpdate)
|
notifier.emitter.on('Update', plugin.onEventUpdate)
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
log.error(e)
|
log.warn(`Unable to load plugin ${pluginFile}: ${String(e)}`)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user