无服务器如何知道在哪里可以找到 serverless.yml?
How does serverless know where to find the serverless.yml?
在项目中本地添加的 npm/yarn serverless package 如何知道 serverless.yml 文件的位置?
我试图在无服务器框架 (https://github.com/serverless/serverless) 的源代码中找到确切的代码片段,这是发生这种情况的地方,但到目前为止还没有找到任何运气。
我需要知道这个因为我的
yarn sls offline start
命令似乎没有我在 serverless.yml 文件中所做的新更改。
它一直在挑选旧的。
这是 Serverless 用来加载配置的代码:
https://github.com/serverless/serverless/blob/master/lib/utils/getServerlessConfigFile.js#L9
相关摘录:
const servicePath = srvcPath || process.cwd();
const jsonPath = path.join(servicePath, 'serverless.json');
const ymlPath = path.join(servicePath, 'serverless.yml');
const yamlPath = path.join(servicePath, 'serverless.yaml');
const jsPath = path.join(servicePath, 'serverless.js');
return BbPromise.props({
json: fileExists(jsonPath),
yml: fileExists(ymlPath),
yaml: fileExists(yamlPath),
js: fileExists(jsPath),
}).then(exists => {
请注意,从 CLI servicePath
设置为当前工作目录。
看看代码,我猜你可能有一个 serverless.json
优先于 serverless.yaml
?命令 serverless print
将显示您已解析的配置。 (https://serverless.com/framework/docs/providers/aws/cli-reference/print/#print)
在项目中本地添加的 npm/yarn serverless package 如何知道 serverless.yml 文件的位置? 我试图在无服务器框架 (https://github.com/serverless/serverless) 的源代码中找到确切的代码片段,这是发生这种情况的地方,但到目前为止还没有找到任何运气。 我需要知道这个因为我的
yarn sls offline start
命令似乎没有我在 serverless.yml 文件中所做的新更改。 它一直在挑选旧的。
这是 Serverless 用来加载配置的代码:
https://github.com/serverless/serverless/blob/master/lib/utils/getServerlessConfigFile.js#L9
相关摘录:
const servicePath = srvcPath || process.cwd();
const jsonPath = path.join(servicePath, 'serverless.json');
const ymlPath = path.join(servicePath, 'serverless.yml');
const yamlPath = path.join(servicePath, 'serverless.yaml');
const jsPath = path.join(servicePath, 'serverless.js');
return BbPromise.props({
json: fileExists(jsonPath),
yml: fileExists(ymlPath),
yaml: fileExists(yamlPath),
js: fileExists(jsPath),
}).then(exists => {
请注意,从 CLI servicePath
设置为当前工作目录。
看看代码,我猜你可能有一个 serverless.json
优先于 serverless.yaml
?命令 serverless print
将显示您已解析的配置。 (https://serverless.com/framework/docs/providers/aws/cli-reference/print/#print)