mirror of
https://github.com/alkimake/paperclip.git
synced 2026-06-14 01:50:39 +09:00
fix(dev-runner): tighten worktree env bootstrap
This commit is contained in:
parent
b6115424b1
commit
a5aed931ab
3 changed files with 13 additions and 5 deletions
|
|
@ -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,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue