refactor: Refactor Serverless.run to async

This commit is contained in:
Piotr Grzesik 2021-01-12 14:00:34 +01:00
parent 77f10f2358
commit 30015eafd2

View File

@ -1,7 +1,6 @@
'use strict';
const path = require('path');
const BbPromise = require('bluebird');
const _ = require('lodash');
const os = require('os');
const fileExists = require('./utils/fs/fileExists');
@ -168,9 +167,9 @@ class Serverless {
}
}
run() {
async run() {
if (this.cli.displayHelp(this.processedInput)) {
return BbPromise.resolve();
return;
}
this.cli.suppressLogIfPrintCommand(this.processedInput);
@ -179,21 +178,21 @@ class Serverless {
// populate variables after --help, otherwise help may fail to print
// (https://github.com/serverless/serverless/issues/2041)
return this.variables.populateService(this.pluginManager.cliOptions).then(() => {
// merge arrays after variables have been populated
// (https://github.com/serverless/serverless/issues/3511)
this.service.mergeArrays();
await this.variables.populateService(this.pluginManager.cliOptions);
// populate function names after variables are loaded in case functions were externalized
// (https://github.com/serverless/serverless/issues/2997)
this.service.setFunctionNames(this.processedInput.options);
// merge arrays after variables have been populated
// (https://github.com/serverless/serverless/issues/3511)
this.service.mergeArrays();
// If in context of servie validate the service configuration
if (this.config.servicePath) this.service.validate();
// populate function names after variables are loaded in case functions were externalized
// (https://github.com/serverless/serverless/issues/2997)
this.service.setFunctionNames(this.processedInput.options);
// trigger the plugin lifecycle when there's something which should be processed
return this.pluginManager.run(this.processedInput.commands);
});
// If in context of service, validate the service configuration
if (this.config.servicePath) this.service.validate();
// trigger the plugin lifecycle when there's something which should be processed
await this.pluginManager.run(this.processedInput.commands);
}
setProvider(name, provider) {