Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pass site to each plugin #655

Merged
merged 1 commit into from
Apr 16, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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