From 537140ccbd26656d9d8e1501e45f680a0e58fab2 Mon Sep 17 00:00:00 2001 From: Daniel Schep Date: Thu, 9 May 2019 09:17:54 -0400 Subject: [PATCH] add a hook for plugins to perform asyncronous initialization. needed for SFE to enable deployment profiles --- lib/Serverless.js | 3 ++- lib/classes/PluginManager.js | 4 ++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/lib/Serverless.js b/lib/Serverless.js index be891e355..697c51065 100644 --- a/lib/Serverless.js +++ b/lib/Serverless.js @@ -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()); diff --git a/lib/classes/PluginManager.js b/lib/classes/PluginManager.js index 433e3dac7..65ee301a9 100644 --- a/lib/classes/PluginManager.js +++ b/lib/classes/PluginManager.js @@ -549,6 +549,10 @@ class PluginManager { } }); } + + asyncPluginInit() { + return BbPromise.map(this.plugins, plugin => (plugin.asyncInit && plugin.asyncInit())); + } } module.exports = PluginManager;