-
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: don't ask anything if flag -y used
- Loading branch information
Showing
5 changed files
with
67 additions
and
27 deletions.
There are no files selected for viewing
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 |
---|---|---|
@@ -1,18 +1,19 @@ | ||
import { execSync } from "node:child_process" | ||
import fs from "fs" | ||
|
||
/** | ||
* This function is used to check if the current git repository is dirty | ||
* @returns boolean | ||
*/ | ||
export function isRepoDirty() { | ||
if (!fs.existsSync(".git")) { | ||
return false | ||
} | ||
|
||
try { | ||
let stdout = execSync("git status --porcelain", { encoding: "utf-8" }) | ||
return stdout.trim() !== "" | ||
} catch (error) { | ||
/** | ||
* If the error message includes "not a git repository", it means that the current directory is not a git repository. | ||
* In this case, we can assume that the repository is clean. | ||
*/ | ||
return !error?.toString?.().includes("not a git repository") | ||
} | ||
} |
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