mirror of
https://github.com/serverless/serverless.git
synced 2026-01-25 15:07:39 +00:00
fix(Variables): Resolve plain text for unrecognized extensions
This commit is contained in:
parent
131516a6d0
commit
d2e6a8adef
@ -134,10 +134,8 @@ module.exports = {
|
||||
}
|
||||
}
|
||||
default:
|
||||
throw new ServerlessError(
|
||||
`Cannot parse "${path.basename(filePath)}": Unsupported file extension`,
|
||||
'UNSUPPORTED_FILE_TYPE'
|
||||
);
|
||||
// Anything else support as plain text
|
||||
return readFile(filePath);
|
||||
}
|
||||
})();
|
||||
|
||||
|
||||
@ -41,7 +41,7 @@ describe('test/unit/lib/configuration/variables/sources/file.test.js', () => {
|
||||
invalidJson: '${file(invalid.json)}',
|
||||
invalidJs: '${file(invalid.js)}',
|
||||
invalidJs2: '${file(invalid2.js)}',
|
||||
invalidExt: '${file(invalid.ext)}',
|
||||
nonStandardExt: '${file(non-standard.ext)}',
|
||||
};
|
||||
variablesMeta = resolveMeta(configuration);
|
||||
await resolve({
|
||||
@ -86,6 +86,11 @@ describe('test/unit/lib/configuration/variables/sources/file.test.js', () => {
|
||||
it('should report with null non existing JS files', () =>
|
||||
expect(configuration.nonExistingJs).to.equal(null));
|
||||
|
||||
it('should resolve plain text content on unrecognized extension', () =>
|
||||
// .trim() as depending on local .git settings and OS (Windows or other)
|
||||
// checked out fixture may end with differen type of EOL (\n on linux, and \r\n on Windows)
|
||||
expect(configuration.nonStandardExt.trim()).to.equal('result: non-standard'.trim()));
|
||||
|
||||
it('should report with an error address argument on primitive content', () =>
|
||||
expect(variablesMeta.get('primitiveAddress').error.code).to.equal('VARIABLE_RESOLUTION_ERROR'));
|
||||
|
||||
@ -141,9 +146,6 @@ describe('test/unit/lib/configuration/variables/sources/file.test.js', () => {
|
||||
expect(variablesMeta.get('invalidJs2').error.code).to.equal('VARIABLE_RESOLUTION_ERROR');
|
||||
});
|
||||
|
||||
it('should report with an error an unrecognized extension', () =>
|
||||
expect(variablesMeta.get('invalidExt').error.code).to.equal('VARIABLE_RESOLUTION_ERROR'));
|
||||
|
||||
it('should not support function resolvers in "js" file sources not confirmed to work with new resolver', async () => {
|
||||
configuration = {
|
||||
jsFunction: '${file(file-function.js)}',
|
||||
|
||||
@ -1 +0,0 @@
|
||||
result: yml
|
||||
@ -0,0 +1 @@
|
||||
result: non-standard
|
||||
Loading…
x
Reference in New Issue
Block a user