Migrate plugins to lib directory
This commit is contained in:
parent
09b29bba56
commit
e7ab8223c2
27 changed files with 869 additions and 858 deletions
23
lib/plugin-helper.js
Normal file
23
lib/plugin-helper.js
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
const _ = require('lodash/fp')
|
||||
|
||||
module.exports = {
|
||||
load,
|
||||
TICKER: 'ticker',
|
||||
EXCHANGE: 'exchange',
|
||||
WALLET: 'wallet',
|
||||
SMS: 'sms',
|
||||
EMAIL: 'email'
|
||||
}
|
||||
|
||||
function load (type, pluginCode) {
|
||||
const me = module.exports
|
||||
if (!_.includes(type, [me.TICKER, me.EXCHANGE, me.WALLET, me.SMS, me.EMAIL])) {
|
||||
throw new Error(`Unallowed plugin type: ${type}`)
|
||||
}
|
||||
|
||||
if (pluginCode.search(/[a-z0-9\-]/) === -1) {
|
||||
throw new Error(`Unallowed plugin name: ${pluginCode}`)
|
||||
}
|
||||
|
||||
return require(`./plugins/${type}/${pluginCode}/${pluginCode}`)
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue