New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Preserve whitespaces in single-quote literal fallback #5775

Merged
merged 2 commits into from Feb 3, 2019
Merged
Changes from all commits
Commits
File filter...
Filter file types
Jump to…
Jump to file or symbol
Failed to load files and symbols.
+12 −2
Diff settings

Always

Just for now

Copy path View file
@@ -294,7 +294,7 @@ class Variables {
this.variableSyntax, this.variableSyntax,
(context, contents) => contents.trim() (context, contents) => contents.trim()
); );
if (!cleaned.match(/".*"/)) { if (!cleaned.match(/".*"|'.*'/)) {
cleaned = cleaned.replace(/\s/g, ''); cleaned = cleaned.replace(/\s/g, '');
} }
return cleaned; return cleaned;
Copy path View file
@@ -786,7 +786,7 @@ describe('Variables', () => {
return serverless.variables.populateObject(service.custom) return serverless.variables.populateObject(service.custom)
.should.become(expected); .should.become(expected);
}); });
it('should preserve whitespace in literal fallback', () => { it('should preserve whitespace in double-quote literal fallback', () => {
service.custom = { service.custom = {
val0: '${self:custom.val, "rate(3 hours)"}', val0: '${self:custom.val, "rate(3 hours)"}',
}; };
@@ -796,6 +796,16 @@ describe('Variables', () => {
return serverless.variables.populateObject(service.custom) return serverless.variables.populateObject(service.custom)
.should.become(expected); .should.become(expected);
}); });
it('should preserve whitespace in single-quote literal fallback', () => {
service.custom = {
val0: '${self:custom.val, \'rate(1 hour)\'}',
};
const expected = {
val0: 'rate(1 hour)',
};
return serverless.variables.populateObject(service.custom)
.should.become(expected);
});
it('should accept whitespace in variables', () => { it('should accept whitespace in variables', () => {
service.custom = { service.custom = {
val0: '${self: custom.val}', val0: '${self: custom.val}',
ProTip! Use n and p to navigate between commits in a pull request.