Skip to content

Commit

Permalink
Update worktree.ts
Browse files Browse the repository at this point in the history
  • Loading branch information
JamesIves committed May 18, 2024
1 parent 4dd89e1 commit bbaccba
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions src/worktree.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,22 @@ export async function generateWorktree(
)
}

await execute(
`git worktree remove ${worktreedir}`,
// Check if the worktree already exists
const {stdout: worktreeList} = await execute(
`git worktree list`,
action.workspace,
action.silent
)

// If the worktree exists, remove it
if (worktreeList.includes(worktreedir)) {
await execute(
`git worktree remove ${worktreedir}`,
action.workspace,
action.silent
)
}

await execute(
`git worktree add --no-checkout --detach ${worktreedir}`,
action.workspace,
Expand Down

0 comments on commit bbaccba

Please sign in to comment.