fix: js/py dotenv unexpectedly overrides existing env vars (#113)

This commit is contained in:
sigoden
2024-10-18 19:28:57 +08:00
committed by GitHub
parent fb62dd5e18
commit 615aa25266
5 changed files with 14 additions and 6 deletions
+4 -1
View File
@@ -75,7 +75,10 @@ async function loadEnv(filePath) {
if (line.trim().startsWith("#") || line.trim() === "") return;
const [key, ...value] = line.split("=");
process.env[key.trim()] = value.join("=").trim();
const envName = key.trim();
if (!process.env[envName]) {
process.env[envName] = value.join("=").trim();
}
});
} catch { }
}