Skip to content

Commit 81ee99d

Browse files
authored
fix(installer): installation if throwing a fatal error when installing in a git worktree
We'll now display a warning when the installer tries to run in git worktree. Ie, `.git` is a file and not a directory. Closes: #15
1 parent 33c0376 commit 81ee99d

1 file changed

Lines changed: 9 additions & 3 deletions

File tree

src/installer.ts

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,17 @@ import { fileSystem } from "@speedy/node-core";
55
const gitRoot = fileSystem.findFileRecursively(".git");
66

77
if (!gitRoot) {
8-
console.log("Not a GIT Repository");
9-
process.exit(0);
8+
console.error("Not a GIT Repository");
9+
process.exit();
1010
}
1111

12-
const hooksPath = path.join(gitRoot!, ".git", "hooks");
12+
const gitPath = path.join(gitRoot!, ".git");
13+
if (!lstatSync(gitPath).isDirectory()) {
14+
console.warn(".git is not a folder. Commit message hook will not be installed.");
15+
process.exit();
16+
}
17+
18+
const hooksPath = path.join(gitPath, "hooks");
1319
const commitMsgHookPath = path.join(hooksPath, "commit-msg");
1420
let fileStat: Stats | undefined;
1521

0 commit comments

Comments
 (0)