Infisical is the open-source platform for securing secrets, certificates, access, and AI Agents.
TypeScript acmeagentsai-agentscertificate-managementdevsecopsenvironment-variableskubernetesopen-sourcepampkipostgresprivate-caprivileged-access-managementsecret-managementsecret-managersecretssecrets-managementsecuritysecurity-toolsvault
import path from "node:path";
const loadEnvFileIfPresent = (envPath: string) => {
try {
process.loadEnvFile(envPath);
} catch (error) {
if ((error as NodeJS.ErrnoException).code !== "ENOENT") {
throw error;
}
}
};
export const loadPackageEnv = (packageRoot: string) => {
loadEnvFileIfPresent(path.join(packageRoot, ".env"));
loadEnvFileIfPresent(path.join(packageRoot, ".env.local"));
};