Reputation: 169
How does npm/yarn serverless packageadded locally in a project know where to locate the serverless.yml file? I am trying to locate the exact piece of code in the source code of serverless framework ( https://github.com/serverless/serverless), where this happens, but haven't had any luck so far. I need to know this because my
yarn sls offline start
command does not seem to the new changes that i did in serverless.yml file. It keeps picking the old one.
Upvotes: 2
Views: 1104
Reputation: 8464
This is the code used by Serverless to load the configuration:
https://github.com/serverless/serverless/blob/master/lib/utils/getServerlessConfigFile.js#L9
Relevant excerpt:
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 => {
Note that from the CLI servicePath
is set to the current working directory.
Looking at the code, my guess is that you may have a serverless.json
which takes precedence over serverless.yaml
? The command serverless print
will show your resolved configuration. (https://serverless.com/framework/docs/providers/aws/cli-reference/print/#print)
Upvotes: 2