chore(db): harden workspace env wrappers

This commit is contained in:
2026-03-31 22:47:07 +02:00
parent 5097ceab7e
commit 3e8b1702bc
6 changed files with 72 additions and 14 deletions
+6 -2
View File
@@ -1,11 +1,15 @@
import { existsSync, readFileSync } from "node:fs";
import { existsSync, readFileSync, realpathSync } from "node:fs";
import { dirname, resolve } from "node:path";
import { fileURLToPath } from "node:url";
function resolveWorkspaceRoot() {
export function resolveWorkspaceRoot() {
return resolve(dirname(fileURLToPath(import.meta.url)), "..");
}
export function resolveRealWorkspaceRoot() {
return realpathSync(resolveWorkspaceRoot());
}
export function resolveWorkspaceEnvPath(options = {}) {
const { workspaceRoot = resolveWorkspaceRoot() } = options;
return resolve(workspaceRoot, ".env");