Skip to content

Commit de570ac

Browse files
authored
Fix/non strings (#867)
Resolves an issue whereby non-strings can be passed into the config switch detector. Closes #866
1 parent e1d66b6 commit de570ac

File tree

3 files changed

+13
-2
lines changed

3 files changed

+13
-2
lines changed

.changeset/unlucky-dragons-fry.md

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'simple-git': patch
3+
---
4+
5+
Resolves an issue whereby non-strings can be passed into the config switch detector.

simple-git/src/lib/plugins/block-unsafe-operations-plugin.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@ import type { SimpleGitPlugin } from './simple-git-plugin';
33
import { GitPluginError } from '../errors/git-plugin-error';
44
import type { SimpleGitPluginConfig } from '../types';
55

6-
function isConfigSwitch(arg: string) {
7-
return arg.trim().toLowerCase() === '-c';
6+
function isConfigSwitch(arg: string | unknown) {
7+
return typeof arg === 'string' && arg.trim().toLowerCase() === '-c';
88
}
99

1010
function preventProtocolOverride(arg: string, next: string) {

simple-git/test/integration/plugin.unsafe.spec.ts

+6
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,12 @@ describe('add', () => {
1313

1414
beforeEach(async () => (context = await createTestContext()));
1515

16+
it('ignores non string arguments', async () => {
17+
const { threw } = await promiseResult(newSimpleGit(context.root).raw([['init']] as any));
18+
19+
expect(threw).toBe(false);
20+
});
21+
1622
it('allows overriding protocol when opting in to unsafe practices', async () => {
1723
const { threw } = await promiseResult(
1824
newSimpleGit(context.root, { unsafe: { allowUnsafeProtocolOverride: true } }).raw(

0 commit comments

Comments
 (0)