Skip to content

Commit

Permalink
Merge pull request #1047 from gperdomor/fix/get-input-list
Browse files Browse the repository at this point in the history
fix(core): fix issue getting prefixed variables
  • Loading branch information
gperdomor authored May 22, 2024
2 parents 77512d4 + 4990bf5 commit 49d7d78
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 49d7d78

Please sign in to comment.