fix(dev-runner): tighten worktree env bootstrap

This commit is contained in:
Dotta 2026-04-11 08:35:53 -05:00
parent b6115424b1
commit a5aed931ab
3 changed files with 13 additions and 5 deletions

View file

@ -17,6 +17,10 @@ function parseEnvFile(contents: string): Record<string, string> {
entries[key] = "";
continue;
}
if (value.startsWith("#")) {
entries[key] = "";
continue;
}
if (
(value.startsWith("\"") && value.endsWith("\"")) ||
@ -32,6 +36,11 @@ function parseEnvFile(contents: string): Record<string, string> {
return entries;
}
type WorktreeEnvBootstrapResult =
| { envPath: null; missingEnv: false }
| { envPath: string; missingEnv: true }
| { envPath: string; missingEnv: false };
export function isLinkedGitWorktreeCheckout(rootDir: string): boolean {
const gitMetadataPath = path.join(rootDir, ".git");
if (!existsSync(gitMetadataPath)) return false;
@ -49,10 +58,7 @@ export function resolveWorktreeEnvFilePath(rootDir: string): string {
export function bootstrapDevRunnerWorktreeEnv(
rootDir: string,
env: NodeJS.ProcessEnv = process.env,
): {
envPath: string | null;
missingEnv: boolean;
} {
): WorktreeEnvBootstrapResult {
if (!isLinkedGitWorktreeCheckout(rootDir)) {
return {
envPath: null,