mirror of
https://github.com/serverless/serverless.git
synced 2026-01-18 14:58:43 +00:00
fix(Plugins): Fix resolution of config when installing plugin
Fixes #7130
This commit is contained in:
parent
e662a91d92
commit
b5dbdafe5b
@ -49,6 +49,7 @@ describe('PluginInstall', () => {
|
||||
beforeEach(() => {
|
||||
serverless = new Serverless();
|
||||
serverless.cli = new CLI(serverless);
|
||||
serverless.processedInput = serverless.cli.processInput();
|
||||
const options = {};
|
||||
pluginInstall = new PluginInstall(serverless, options);
|
||||
consoleLogStub = sinon.stub(serverless.cli, 'consoleLog').returns();
|
||||
|
||||
@ -4,10 +4,9 @@ const fetch = require('node-fetch');
|
||||
const BbPromise = require('bluebird');
|
||||
const HttpsProxyAgent = require('https-proxy-agent');
|
||||
const url = require('url');
|
||||
const path = require('path');
|
||||
const chalk = require('chalk');
|
||||
const _ = require('lodash');
|
||||
const fileExists = require('../../../utils/fs/fileExists');
|
||||
const { getServerlessConfigFilePath } = require('../../../utils/getServerlessConfigFile');
|
||||
|
||||
module.exports = {
|
||||
validate() {
|
||||
@ -21,29 +20,10 @@ module.exports = {
|
||||
},
|
||||
|
||||
getServerlessFilePath() {
|
||||
const servicePath = this.serverless.config.servicePath;
|
||||
const ymlFilePath = path.join(servicePath, 'serverless.yml');
|
||||
const yamlFilePath = path.join(servicePath, 'serverless.yaml');
|
||||
const jsonFilePath = path.join(servicePath, 'serverless.json');
|
||||
const jsFilePath = path.join(servicePath, 'serverless.js');
|
||||
|
||||
return BbPromise.props({
|
||||
json: fileExists(jsonFilePath),
|
||||
yml: fileExists(ymlFilePath),
|
||||
yaml: fileExists(yamlFilePath),
|
||||
js: fileExists(jsFilePath),
|
||||
}).then(exists => {
|
||||
if (exists.yml) {
|
||||
return ymlFilePath;
|
||||
} else if (exists.yaml) {
|
||||
return yamlFilePath;
|
||||
} else if (exists.json) {
|
||||
return jsonFilePath;
|
||||
} else if (exists.js) {
|
||||
return jsFilePath;
|
||||
}
|
||||
return BbPromise.reject(
|
||||
new this.serverless.classes.Error('Could not find any serverless service definition file.')
|
||||
return getServerlessConfigFilePath(this.serverless).then(filePath => {
|
||||
if (filePath) return filePath;
|
||||
throw new this.serverless.classes.Error(
|
||||
'Could not find any serverless service definition file.'
|
||||
);
|
||||
});
|
||||
},
|
||||
|
||||
@ -40,6 +40,7 @@ describe('PluginUtils', () => {
|
||||
beforeEach(() => {
|
||||
serverless = new Serverless();
|
||||
serverless.cli = new CLI(serverless);
|
||||
serverless.processedInput = serverless.cli.processInput();
|
||||
const options = {};
|
||||
pluginUtils = new PluginInstall(serverless, options);
|
||||
consoleLogStub = sinon.stub(serverless.cli, 'consoleLog').returns();
|
||||
|
||||
@ -43,6 +43,7 @@ describe('PluginUninstall', () => {
|
||||
beforeEach(() => {
|
||||
serverless = new Serverless();
|
||||
serverless.cli = new CLI(serverless);
|
||||
serverless.processedInput = serverless.cli.processInput();
|
||||
const options = {};
|
||||
pluginUninstall = new PluginUninstall(serverless, options);
|
||||
consoleLogStub = sinon.stub(serverless.cli, 'consoleLog').returns();
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user