embed plugins
This commit is contained in:
@@ -84,15 +84,7 @@ const pluginController = {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
_load() {
|
_loadPlugin (pluginFile) {
|
||||||
// load custom plugins
|
|
||||||
const plugins_path = config.plugins_path || path.resolve(process.env.cwd || '', 'plugins')
|
|
||||||
log.info(`Loading plugin ${plugins_path}`)
|
|
||||||
if (fs.existsSync(plugins_path)) {
|
|
||||||
const plugins = fs.readdirSync(plugins_path)
|
|
||||||
.map(e => path.resolve(plugins_path, e, 'index.js'))
|
|
||||||
.filter(index => fs.existsSync(index))
|
|
||||||
plugins.forEach(pluginFile => {
|
|
||||||
try {
|
try {
|
||||||
const plugin = require(pluginFile)
|
const plugin = require(pluginFile)
|
||||||
const name = plugin.configuration.name
|
const name = plugin.configuration.name
|
||||||
@@ -109,7 +101,22 @@ const pluginController = {
|
|||||||
} catch (e) {
|
} catch (e) {
|
||||||
log.warn(`Unable to load plugin ${pluginFile}: ${String(e)}`)
|
log.warn(`Unable to load plugin ${pluginFile}: ${String(e)}`)
|
||||||
}
|
}
|
||||||
})
|
},
|
||||||
|
|
||||||
|
_load() {
|
||||||
|
// load custom plugins
|
||||||
|
const system_plugins_path = path.resolve(__dirname || '', '../../../gancio_plugins')
|
||||||
|
const custom_plugins_path = config.plugins_path || path.resolve(process.env.cwd || '', 'plugins')
|
||||||
|
const plugins_paths = custom_plugins_path === system_plugins_path ? [custom_plugins_path] : [custom_plugins_path, system_plugins_path]
|
||||||
|
|
||||||
|
log.info(`Loading plugins from ${plugins_paths.join(' and ')}`)
|
||||||
|
for (const plugins_path of plugins_paths) {
|
||||||
|
if (fs.existsSync(plugins_path)) {
|
||||||
|
fs.readdirSync(plugins_path)
|
||||||
|
.map(e => path.resolve(plugins_path, e, 'index.js'))
|
||||||
|
.filter(index => fs.existsSync(index))
|
||||||
|
.forEach(pluginController._loadPlugin)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user