Skip to content

Commit 0402ac6

Browse files
authored
Merge pull request #103 from salesforcecli/ew/vararg-generic
fix: parse varargs response type
2 parents 4194e3e + 35b1aa9 commit 0402ac6

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

src/util.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,8 @@ export function toHelpSection(
6262
return { header, body };
6363
}
6464

65-
export function parseVarArgs(args: Record<string, unknown>, argv: string[]): Record<string, unknown> {
66-
const final: Record<string, unknown> = {};
65+
export function parseVarArgs(args: Record<string, unknown>, argv: string[]): Record<string, string | undefined> {
66+
const final: Record<string, string | undefined> = {};
6767
const argVals = Object.values(args);
6868

6969
// Remove arguments from varargs

test/unit/util.test.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,16 @@ describe('parseVarArgs', () => {
9393
expect(varargs).to.deep.equal({ key1: 'value1' });
9494
});
9595

96+
it('should parse multiple varargs', () => {
97+
const varargs = parseVarArgs({}, ['key1=value1', 'key2=value2']);
98+
expect(varargs).to.deep.equal({ key1: 'value1', key2: 'value2' });
99+
});
100+
101+
it('should allow an empty value', () => {
102+
const varargs = parseVarArgs({}, ['key1=']);
103+
expect(varargs).to.deep.equal({ key1: undefined });
104+
});
105+
96106
it('should parse varargs and not arguments', () => {
97107
const varargs = parseVarArgs({ arg1: 'foobar' }, ['foobar', 'key1=value1']);
98108
expect(varargs).to.deep.equal({ key1: 'value1' });

0 commit comments

Comments
 (0)