Skip to content

Commit

Permalink
Plugins will only be ran when included in .env
Browse files Browse the repository at this point in the history
  • Loading branch information
jtpox committed Jun 22, 2018
1 parent 815aab1 commit 4ba9d17
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 4 deletions.
5 changes: 5 additions & 0 deletions .env
Original file line number Diff line number Diff line change
@@ -1,25 +1,30 @@
PORT=8080
SECURE_PORT=8081

#Site Details
SITE_NAME=ribbon
SITE_DOMAIN=
SITE_THEME=flac
ADMIN_THEME=arabesque/dist

HASH_SALT_ROUNDS=10

#Database Information
DB_HOST=localhost
DB_PORT=27017
DB_USER=
DB_PASSWORD=
DB_AUTH=admin
DB_NAME=ribbon

#Analytics
GOOGLE_TRACKING_ID=

TWITTER_USERNAME=

#Certificates. Not recommended to use this. Use a proxy server instead (E.g. nginx).
SECURE_PRIVATE_KEY=
SECURE_PRIVATE_CERT=

#Seperate with comments (E.g. example-plugin,plugin-2)
PLUGINS=example-plugin
12 changes: 8 additions & 4 deletions app/ribbon.js
Original file line number Diff line number Diff line change
Expand Up @@ -151,13 +151,17 @@ class Ribbon {
*/
load_plugins() {
const plugins = this.get_plugin_directories();
const enabled = process.env.plugins.split(',');

plugins.forEach((file) => {
// Retrieve package.json.
/* eslint-disable */
require(`./plugin/${file}`)(this.app, this.log); // eslint-disable-line global-require

//Retrieve package.json.
const plugin_info = require(`./plugin/${file}/package.json`);
this.log.info(`Plugin - ${plugin_info.name} (${plugin_info.version})`);
if (enabled.indexOf(plugin_info.name) !== -1) {
require(`./plugin/${file}`)(this.app, this.log); // eslint-disable-line global-require

this.log.plugin(`${plugin_info.name} (${plugin_info.version})`);
}
/* eslint-enable */
});
}
Expand Down
9 changes: 9 additions & 0 deletions ribbon.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,5 +33,14 @@ const ribbon = new Ribbon(
new transports.Console(),
new transports.File({ filename: 'combined.log' }),
],
levels: {
error: 0,
warn: 1,
info: 2,
plugin: 2,
verbose: 3,
debug: 4,
silly: 5,
},
}),
);

0 comments on commit 4ba9d17

Please sign in to comment.