populate environment variables again finds the repo env file

This commit is contained in:
Jarek Krochmalski committed 2026-09-02 15:52:44 +02:00
1 parent 34ceb74dc1
commit d03554c69d
3 files changed
+74 -13

No files matched your search

+12 -1
View File
@@ -8,7 +8,7 @@
* git@host:path) passes unchanged, so this is fully backward-compatible.
*/
import { resolve, sep } from 'node:path';
import { resolve, sep, join, dirname } from 'node:path';
export function assertSafeRepoUrl(url: string): void {
const u = (url || '').trim();
@@ -51,3 +51,14 @@ export function repoFilePath(repoPath: string, userRel: string, label: string):
}
return abs;
}
/**
* Absolute path of the base `.env` that sits beside a compose file inside a clone. The
* compose path is resolved through repoFilePath (containment-checked, ABSOLUTE), so the
* `.env` is just its sibling - NOT re-joined onto repoPath, which would double the prefix
* (#1495).
*/
export function repoBaseEnvPath(repoPath: string, composeUserPath: string): string {
const safeComposePath = repoFilePath(repoPath, composeUserPath, 'Compose path');
return join(dirname(safeComposePath), '.env');
}