Skip to content

Commit

Permalink
pass site to each plugin (#655)
Browse files Browse the repository at this point in the history
  • Loading branch information
james-owen authored Apr 16, 2019
1 parent 9443c88 commit 47dc34e
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
2 changes: 1 addition & 1 deletion lib/routes.js
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ function addSite(router, { providers, sessionStore }, site) {
siteRouter.use(addAvailableComponents);

// Plugins can add routes to a site, fire that hook now to register those routes
return plugins.initPlugins(siteRouter)
return plugins.initPlugins(siteRouter, site)
.then(() => {
const siteControllerConfig = site.dir ? files.tryRequire(site.dir) : {},
midleware = _.get(siteControllerConfig, 'middleware', null);
Expand Down
5 changes: 3 additions & 2 deletions lib/services/plugins.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,14 @@ var log = require('./logger').setup({
* of the bus service.
*
* @param {Object} router
* @param {Object} site
* @returns {Promise}
*/
function initPlugins(router) {
function initPlugins(router, site) {
return bluebird.all(module.exports.plugins.map(plugin => {
return bluebird.try(() => {
if (typeof plugin === 'function') {
return plugin(router, pluginDBAdapter, publish, sites);
return plugin(router, pluginDBAdapter, publish, sites, site);
} else {
log('warn', 'Plugin is not a function');
return bluebird.resolve();
Expand Down

0 comments on commit 47dc34e

Please sign in to comment.