Skip to content

Commit 6186a14

Browse files
authored
fix: CLI init doesn't work outside of a GIT repo (#405)
1 parent 916a353 commit 6186a14

File tree

2 files changed

+17
-2
lines changed

2 files changed

+17
-2
lines changed

.changeset/mighty-melons-vanish.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@trigger.dev/cli": patch
3+
---
4+
5+
fix: init will no longer fail when outside of a git repo

packages/cli/src/commands/init.ts

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -253,9 +253,19 @@ const resolveOptionsWithPrompts = async (
253253
// Detects if there are any uncommitted git changes at path
254254
async function detectGitChanges(path: string): Promise<boolean> {
255255
const git = simpleGit(path);
256-
const status = await git.status();
257256

258-
return status.files.length > 0;
257+
try {
258+
const isRepo = await git.checkIsRepo();
259+
260+
if (isRepo) {
261+
// Check if there are uncommitted changes
262+
const status = await git.status();
263+
return status.files.length > 0;
264+
}
265+
return false;
266+
} catch (error) {
267+
return false;
268+
}
259269
}
260270

261271
async function detectTypescriptProject(path: string): Promise<boolean> {

0 commit comments

Comments
 (0)