diff --git a/src/cli.ts b/src/cli.ts index 0d667cc..a0632d2 100755 --- a/src/cli.ts +++ b/src/cli.ts @@ -3,6 +3,7 @@ import { Command } from "commander" import { basename, join } from "path" import { homedir } from "os" +import { mkdir, symlink, unlink } from "fs/promises" import * as git from "./git.ts" import * as vm from "./vm.ts" import * as state from "./state.ts" @@ -33,6 +34,8 @@ program const spin = spinner("Creating worktree") await git.createWorktree(branch, worktreeAbs, root) + await mkdir(join(root, '.sandlot'), { recursive: true }) + await symlink(worktreeAbs, join(root, '.sandlot', branch)) spin.text = "Starting VM" await vm.ensure() @@ -105,6 +108,7 @@ const closeAction = async (branch: string) => { const worktreeAbs = session?.worktree ?? join(homedir(), '.sandlot', basename(root), branch) await git.removeWorktree(worktreeAbs, root) + await unlink(join(root, '.sandlot', branch)).catch(() => {}) console.log(`Removed worktree ${worktreeAbs}/`) await git.deleteLocalBranch(branch, root)