Skip to content

Commit d6e12e9

Browse files
committed
Allow passing repeated flags to git commands
1 parent 34c5eba commit d6e12e9

File tree

3 files changed

+10
-1
lines changed

3 files changed

+10
-1
lines changed

simple-git/src/lib/types/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ export type TaskOptions<O extends Options = Options> = string[] | O;
1717
/**
1818
* Options supplied in most tasks as an optional trailing object
1919
*/
20-
export type OptionsValues = null | string | number;
20+
export type OptionsValues = null | string | number | (string | number)[];
2121
export type Options = Record<string, OptionsValues>;
2222

2323
export type OptionFlags<FLAGS extends string, VALUE = null> = Partial<Record<FLAGS, VALUE>>;

simple-git/src/lib/utils/task-options.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@ export function appendTaskOptions<T extends Options = Options>(
2424
commands.push(value);
2525
} else if (filterPrimitives(value, ['boolean'])) {
2626
commands.push(key + '=' + value);
27+
} else if (Array.isArray(value)) {
28+
commands.push(...value.map((v) => key + '=' + v));
2729
} else {
2830
commands.push(key);
2931
}

simple-git/test/unit/push.spec.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,13 @@ describe('push', () => {
6565
assertExecutedCommands('push', '--follow-tags', ...defaultCommands);
6666
});
6767

68+
it('git push with multiple --push-options', async () => {
69+
git.push({ '--push-option': ["foo", "foo=bar", 123] });
70+
await closeWithSuccess();
71+
72+
assertExecutedCommands('push', '--push-option=foo', '--push-option=foo=bar', '--push-option=123', ...defaultCommands);
73+
});
74+
6875
it('git push with remote/branch and options', async () => {
6976
git.push('rrr', 'bbb', { '--follow-tags': null });
7077
await closeWithSuccess();

0 commit comments

Comments
 (0)