Skip to content

Commit

Permalink
fix(core): fix issue getting prefixed variables
Browse files Browse the repository at this point in the history
fix issue getting prefixed variables for lists

fix #1045
  • Loading branch information
gperdomor committed May 22, 2024
1 parent 77512d4 commit 4990bf5
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
16 changes: 16 additions & 0 deletions packages/core/src/lib/get-input-list.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,22 @@ ccccccccc`,
setInput('outputs', output);
expect(getInputList('outputs', { ignoreComma: true, quote: false })).toEqual([output]);
});

describe('prefix', () => {
it('getInputList should use return prefixed value if prefixed input exists', async () => {
await setInput('foo', 'bar');
await setInput('prefixed-foo', 'prefixed-bar');

const res = getInputList('foo', { prefix: 'prefixed' });
expect(res).toEqual(['prefixed-bar']);
});

it('getInputList should use return unprefixed value if prefixed input is missing', async () => {
await setInput('abc', 'bar,xyz');
expect(getInputList('abc', { prefix: 'prefixed' })).toEqual(['bar', 'xyz']);
expect(getInputList('abc')).toEqual(['bar', 'xyz']);
});
});
});

function setInput(name: string, value: string): void {
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/lib/get-input-list.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export interface ListOpts {
}

export function getInputList(name: string, opts?: ListOpts): string[] {
return getList(getInput(name), opts);
return getList(getInput(name, { prefix: opts?.prefix }), opts);
}

export function getList(input: string, opts?: ListOpts): string[] {
Expand Down

0 comments on commit 4990bf5

Please sign in to comment.