-
Notifications
You must be signed in to change notification settings - Fork 116
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
31 additions
and
21 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import { execSync } from "child_process"; | ||
|
||
// 检查全局是否安装了 Git | ||
const hasGit = (): boolean => { | ||
try { | ||
execSync("git --version"); | ||
return true; // Git已安装 | ||
} catch (error) { | ||
return false; // Git未安装 | ||
} | ||
}; | ||
|
||
// 检查项目是否已经有 Git 环境 | ||
const hasProjectGit = (cwd: string): boolean => { | ||
try { | ||
execSync("git status", { stdio: "ignore", cwd }); | ||
return true; | ||
} catch (error) { | ||
return false; | ||
} | ||
}; | ||
|
||
export default function gitCheck(rootDirectory: string): boolean { | ||
if (!hasGit()) return false; | ||
return !hasProjectGit(rootDirectory); | ||
} |