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

Lines changed: 5 additions & 0 deletions
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

Lines changed: 2 additions & 2 deletions
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

Lines changed: 6 additions & 0 deletions
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)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy