Skip to content
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

fix(cli): equals sign in a context value is dropped #5773

Merged
merged 9 commits into from
Jan 23, 2020
2 changes: 1 addition & 1 deletion packages/aws-cdk/lib/settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,7 @@ export class Settings {
const context: any = {};

for (const assignment of ((argv as any).context || [])) {
const parts = assignment.split('=', 2);
const parts = assignment.split(/=(.*)/, 2);
if (parts.length === 2) {
debug('CLI argument context: %s=%s', parts[0], parts[1]);
if (parts[0].match(/^aws:.+/)) {
Expand Down
20 changes: 20 additions & 0 deletions packages/aws-cdk/test/settings.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,3 +59,23 @@ test('can clear all values in all objects', () => {
expect(settings1.all).toEqual({ });
expect(settings2.all).toEqual({});
});

test('can parse string context from command line arguments', () => {
// GIVEN
const settings1 = Settings.fromCommandLineArguments({ context: ['foo=bar'] });
const settings2 = Settings.fromCommandLineArguments({ context: ['foo='] });

// THEN
expect(settings1.get(['context']).foo).toEqual( 'bar');
expect(settings2.get(['context']).foo).toEqual( '');
});

test('can parse string context from command line arguments with equals sign in value', () => {
// GIVEN
const settings1 = Settings.fromCommandLineArguments({ context: ['foo==bar='] });
const settings2 = Settings.fromCommandLineArguments({ context: ['foo=bar='] });

// THEN
expect(settings1.get(['context']).foo).toEqual( '=bar=');
expect(settings2.get(['context']).foo).toEqual( 'bar=');
});