fix: rethrow non-ENOENT errors when loading .env

This commit is contained in:
Amruth Pillai
2026-07-03 20:55:41 +02:00
parent 0ba44865c7
commit 5b8ab33888
+4 -4
View File
@@ -7,11 +7,11 @@ const workspaceRoot = findWorkspaceRoot();
if (workspaceRoot) {
try {
// ponytail: native stand-in for dotenv. loadEnvFile throws when .env is absent
// (e.g. production with injected env), and existing process.env still wins — so just tolerate a miss.
// Native stand-in for dotenv: existing process.env still wins over file values.
process.loadEnvFile(join(workspaceRoot, ".env"));
} catch {
// no .env file — rely on the ambient process environment
} catch (error) {
// A missing .env is expected (e.g. production with injected env); anything else is a real problem.
if (!(error instanceof Error && "code" in error && error.code === "ENOENT")) throw error;
}
}