From 350cf7e2d94aa29cdbd95b1891e1c81c4685e299 Mon Sep 17 00:00:00 2001 From: Joscha Feth Date: Fri, 3 Sep 2021 10:13:39 +1000 Subject: [PATCH] feat: parameter overrides support double escape BREAKING CHANGE --- src/__tests__/command.spec.ts | 11 ++++++++++- src/steps/command.ts | 2 +- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/src/__tests__/command.spec.ts b/src/__tests__/command.spec.ts index a9feb29..fa9f8da 100644 --- a/src/__tests__/command.spec.ts +++ b/src/__tests__/command.spec.ts @@ -383,7 +383,16 @@ describe('buildkite-graph', () => { .withParameterOverride('priority', 'MY_PRIORITY') .toJson(), ).resolves.toEqual( - expect.objectContaining({ priority: '${MY_PRIORITY}' }), + expect.objectContaining({ priority: '$MY_PRIORITY' }), + ); + }); + it('supports double escape', async () => { + await expect( + new CommandStep('noop') + .withParameterOverride('priority', '$MY_PRIORITY') + .toJson(), + ).resolves.toEqual( + expect.objectContaining({ priority: '$$MY_PRIORITY' }), ); }); }); diff --git a/src/steps/command.ts b/src/steps/command.ts index c80c851..98b9365 100644 --- a/src/steps/command.ts +++ b/src/steps/command.ts @@ -285,7 +285,7 @@ export class CommandStep extends LabeledStep { private valueWithOverride(value: T, key: CommandProperty): string | T { if (this.overrides.has(key)) { - return `$\{${this.overrides.get(key) as string}}`; + return ('$' + this.overrides.get(key)) as string; } return value; }