UNPKG

@iqai/adk-cli

Version:

CLI tool for creating, running, and testing ADK-TS agents

44 lines 1.96 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.loadEnvironmentVariables = loadEnvironmentVariables; const node_fs_1 = require("node:fs"); const node_path_1 = require("node:path"); const find_project_root_1 = require("../../../common/find-project-root"); function loadEnvironmentVariables(agentFilePath, logger) { const normalizedAgentPath = (0, node_path_1.normalize)((0, node_path_1.resolve)(agentFilePath)); const projectRoot = (0, find_project_root_1.findProjectRoot)((0, node_path_1.dirname)(normalizedAgentPath)); const envFiles = [ ".env.local", ".env.development.local", ".env.production.local", ".env.development", ".env.production", ".env", ]; for (const envFile of envFiles) { const envPath = (0, node_path_1.join)(projectRoot, envFile); if ((0, node_fs_1.existsSync)(envPath)) { try { const envContent = (0, node_fs_1.readFileSync)(envPath, "utf8"); const envLines = envContent.split("\n"); for (const line of envLines) { const trimmedLine = line.trim(); if (trimmedLine && !trimmedLine.startsWith("#")) { const [key, ...valueParts] = trimmedLine.split("="); if (key && valueParts.length > 0) { const value = valueParts.join("=").replace(/^"(.*)"$/, "$1"); if (!process.env[key.trim()]) { process.env[key.trim()] = value.trim(); } } } } } catch (error) { const msg = error instanceof Error ? error.message : String(error); logger?.warn(`Warning: Could not load ${envFile} file: ${msg}`); } } } } //# sourceMappingURL=env.js.map