1
- import { spawnSync } from "child_process" ;
2
1
import debug from "debug" ;
3
2
import * as fsPromises from "fs/promises" ;
4
3
import type { FileSystemAdapter } from "obsidian" ;
@@ -27,7 +26,7 @@ import type {
27
26
Status ,
28
27
} from "../types" ;
29
28
import { CurrentGitAction , NoNetworkError } from "../types" ;
30
- import { impossibleBranch , splitRemoteBranch } from "../utils" ;
29
+ import { impossibleBranch , spawnAsync , splitRemoteBranch } from "../utils" ;
31
30
import { GitManager } from "./gitManager" ;
32
31
33
32
export class SimpleGit extends GitManager {
@@ -40,7 +39,7 @@ export class SimpleGit extends GitManager {
40
39
}
41
40
42
41
async setGitInstance ( ignoreError = false ) : Promise < void > {
43
- if ( this . isGitInstalled ( ) ) {
42
+ if ( await this . isGitInstalled ( ) ) {
44
43
const adapter = this . app . vault . adapter as FileSystemAdapter ;
45
44
const vaultBasePath = adapter . getBasePath ( ) ;
46
45
let basePath = vaultBasePath ;
@@ -736,7 +735,7 @@ export class SimpleGit extends GitManager {
736
735
async checkRequirements ( ) : Promise <
737
736
"valid" | "missing-repo" | "missing-git"
738
737
> {
739
- if ( ! this . isGitInstalled ( ) ) {
738
+ if ( ! ( await this . isGitInstalled ( ) ) ) {
740
739
return "missing-git" ;
741
740
}
742
741
if ( ! ( await this . git . checkIsRepo ( ) ) ) {
@@ -1045,21 +1044,19 @@ export class SimpleGit extends GitManager {
1045
1044
}
1046
1045
}
1047
1046
1048
- private isGitInstalled ( ) : boolean {
1047
+ private async isGitInstalled ( ) : Promise < boolean > {
1049
1048
// https://github.com/steveukx/git-js/issues/402
1050
1049
const gitPath = this . plugin . localStorage . getGitPath ( ) ;
1051
- const command = spawnSync ( gitPath || "git" , [ "--version" ] , {
1052
- stdio : "ignore" ,
1053
- } ) ;
1050
+ const command = await spawnAsync ( gitPath || "git" , [ "--version" ] , { } ) ;
1054
1051
1055
1052
if ( command . error ) {
1056
1053
if ( Platform . isWin && ! gitPath ) {
1057
1054
this . plugin . log (
1058
1055
`Git not found in PATH. Checking standard installation path(${ DEFAULT_WIN_GIT_PATH } ) of Git for Windows.`
1059
1056
) ;
1060
- const command = spawnSync ( DEFAULT_WIN_GIT_PATH , [ "--version" ] , {
1061
- stdio : "ignore ",
1062
- } ) ;
1057
+ const command = await spawnAsync ( DEFAULT_WIN_GIT_PATH , [
1058
+ "--version ",
1059
+ ] ) ;
1063
1060
if ( command . error ) {
1064
1061
console . error ( command . error ) ;
1065
1062
return false ;
0 commit comments