UNPKG

cmte

Version:

Design by Committee™ except it's just you and LLMs

25 lines (23 loc) 719 B
import { fileURLToPath } from 'url'; import { dirname } from 'path'; import path from 'path'; import { config } from 'dotenv'; import { logger } from './logger.js'; /** * Load environment variables from .env file */ export function loadEnvVars() { const __filename = fileURLToPath(import.meta.url); const __dirname = dirname(__filename); const ROOT_DIR = path.resolve(__dirname, '../..'); // Load environment variables from .env file in the root directory const result = config({ path: path.join(ROOT_DIR, '.env') }); logger.debug('Loaded environment variables:', { loaded: result.parsed !== undefined, error: result.error, envPath: path.join(ROOT_DIR, '.env') }); return result; }