Merge pull request #5793 from serverless/fix-yml-race-condition

Fix race condition when loading config file
This commit is contained in:
Philipp Muens 2019-02-05 13:23:20 +01:00 committed by GitHub
commit 4a64f4a7bc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 22 additions and 21 deletions

View File

@ -55,27 +55,26 @@ class Serverless {
// get an array of commands and options that should be processed
this.processedInput = this.cli.processInput();
// make the serverless config file available to the PluginManager
this.pluginManager.loadConfigFile();
// load config file
return this.pluginManager.loadConfigFile().then(() => {
// set the options and commands which were processed by the CLI
this.pluginManager.setCliOptions(this.processedInput.options);
this.pluginManager.setCliCommands(this.processedInput.commands);
// set the options and commands which were processed by the CLI
this.pluginManager.setCliOptions(this.processedInput.options);
this.pluginManager.setCliCommands(this.processedInput.commands);
// Check if update is available
updateNotifier({ pkg }).notify();
// Check if update is available
updateNotifier({ pkg }).notify();
return this.service.load(this.processedInput.options);
}).then(() => {
// load all plugins
this.pluginManager.loadAllPlugins(this.service.plugins);
return this.service.load(this.processedInput.options)
.then(() => {
// load all plugins
this.pluginManager.loadAllPlugins(this.service.plugins);
// 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());
this.cli.setLoadedCommands(this.pluginManager.getCommands());
return this.pluginManager.updateAutocompleteCacheFile();
});
// 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());
this.cli.setLoadedCommands(this.pluginManager.getCommands());
return this.pluginManager.updateAutocompleteCacheFile();
});
}
run() {

View File

@ -42,9 +42,11 @@ class PluginManager {
}
loadConfigFile() {
getServerlessConfigFile(this.serverless.config.servicePath).then((serverlessConfigFile) => {
this.serverlessConfigFile = serverlessConfigFile;
});
return getServerlessConfigFile(this.serverless.config.servicePath)
.then((serverlessConfigFile) => {
this.serverlessConfigFile = serverlessConfigFile;
return;
});
}
setCliOptions(options) {