add a hook for plugins to perform asyncronous initialization.

needed for SFE to enable deployment profiles
This commit is contained in:
Daniel Schep 2019-05-09 09:17:54 -04:00
parent 0626d5b5df
commit 537140ccbd
2 changed files with 6 additions and 1 deletions

View File

@ -70,7 +70,8 @@ class Serverless {
}).then(() => {
// load all plugins
this.pluginManager.loadAllPlugins(this.service.plugins);
return this.pluginManager.asyncPluginInit();
}).then(() => {
// give the CLI the plugins and commands so that it can print out
// information such as options when the user enters --help
this.cli.setLoadedPlugins(this.pluginManager.getPlugins());

View File

@ -549,6 +549,10 @@ class PluginManager {
}
});
}
asyncPluginInit() {
return BbPromise.map(this.plugins, plugin => (plugin.asyncInit && plugin.asyncInit()));
}
}
module.exports = PluginManager;