Skip to content

Commit c1b65ea

Browse files
committed
refactor(git): use spawnSync from @socketsecurity/lib
Replace Node.js native child_process.spawnSync with @socketsecurity/lib/spawn spawnSync for consistent cross-platform process spawning. Export getGitRemoteUrlSync for testing purposes.
1 parent 82ef75f commit c1b65ea

1 file changed

Lines changed: 5 additions & 4 deletions

File tree

packages/cli/src/utils/git/provider-factory.mts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { spawnSync } from 'node:child_process'
1+
import { spawnSync } from '@socketsecurity/lib/spawn'
22

33
import type { PrProvider } from './provider.mts'
44

@@ -9,7 +9,7 @@ import type { PrProvider } from './provider.mts'
99
* Falls back to GitHub for backward compatibility.
1010
*/
1111
export function createPrProvider(): PrProvider {
12-
const remoteUrl = getGitRemoteUrl()
12+
const remoteUrl = getGitRemoteUrlSync()
1313

1414
// Check for GitLab.
1515
if (
@@ -30,11 +30,12 @@ export function createPrProvider(): PrProvider {
3030
}
3131

3232
/**
33-
* Gets the git remote origin URL.
33+
* Gets the git remote origin URL synchronously.
3434
*
3535
* Uses `git config` to read the remote.origin.url setting.
36+
* Exported for testing purposes.
3637
*/
37-
function getGitRemoteUrl(): string {
38+
export function getGitRemoteUrlSync(): string {
3839
try {
3940
const result = spawnSync('git', ['config', '--get', 'remote.origin.url'], {
4041
encoding: 'utf8',

0 commit comments

Comments
 (0)