mirror of
https://github.com/serverless/serverless.git
synced 2026-02-01 16:07:28 +00:00
Merge pull request #6631 from serverless/improve-yaml-parse
Resolve empty config object for an empty config file
This commit is contained in:
commit
1cad7b88fb
@ -70,7 +70,7 @@ const getServerlessConfigFile = _.memoize(
|
||||
return handleJsConfigFile(configFilePath);
|
||||
}
|
||||
|
||||
return readFile(configFilePath);
|
||||
return readFile(configFilePath).then(result => result || {});
|
||||
}
|
||||
|
||||
return '';
|
||||
|
||||
@ -33,6 +33,20 @@ describe('#getServerlessConfigFile()', () => {
|
||||
});
|
||||
});
|
||||
|
||||
it('should return an empty object for empty configuration', () => {
|
||||
const serverlessFilePath = path.join(tmpDirPath, 'serverless.yml');
|
||||
|
||||
writeFileSync(serverlessFilePath, '');
|
||||
return expect(
|
||||
getServerlessConfigFile({
|
||||
processedInput: { options: {} },
|
||||
config: { servicePath: tmpDirPath },
|
||||
})
|
||||
).to.be.fulfilled.then(result => {
|
||||
expect(result).to.deep.equal({});
|
||||
});
|
||||
});
|
||||
|
||||
it('should return the file content if a serverless.yml file is found', () => {
|
||||
const serverlessFilePath = path.join(tmpDirPath, 'serverless.yml');
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user