UNPKG

@intlayer/config

Version:

Retrieve Intlayer configurations and manage environment variables for both server-side and client-side environments.

28 lines (26 loc) 666 B
import { existsSync } from "node:fs"; import dotenv from "dotenv"; //#region src/loadEnvFile.ts const DEFAULT_ENV = "development"; const getEnvFilePath = (env = "development", envFile) => { return (envFile ? [envFile] : [ `.env.${env}.local`, `.env.${env}`, ".env.local", ".env" ]).find(existsSync); }; const loadEnvFile = (options) => { const envFiles = getEnvFilePath(options?.env ?? DEFAULT_ENV, options?.envFile); if (!envFiles) return {}; const result = {}; dotenv.config({ path: envFiles, processEnv: result, quiet: true }); return result; }; //#endregion export { getEnvFilePath, loadEnvFile }; //# sourceMappingURL=loadEnvFile.mjs.map