YAML config takes priority over .env
This commit is contained in:
@@ -143,15 +143,14 @@ export function configToEnv(config: LettaBotConfig): Record<string, string> {
|
||||
}
|
||||
|
||||
/**
|
||||
* Apply config to process.env
|
||||
* Apply config to process.env (YAML config takes priority over .env)
|
||||
*/
|
||||
export function applyConfigToEnv(config: LettaBotConfig): void {
|
||||
const env = configToEnv(config);
|
||||
for (const [key, value] of Object.entries(env)) {
|
||||
if (!process.env[key]) {
|
||||
// YAML config always takes priority
|
||||
process.env[key] = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -5,13 +5,15 @@
|
||||
* Chat continues seamlessly between Telegram, Slack, and WhatsApp.
|
||||
*/
|
||||
|
||||
// Load .env first for backwards compatibility
|
||||
import 'dotenv/config';
|
||||
|
||||
import { createServer } from 'node:http';
|
||||
import { existsSync, mkdirSync, readFileSync, readdirSync } from 'node:fs';
|
||||
import { resolve } from 'node:path';
|
||||
import { spawn } from 'node:child_process';
|
||||
|
||||
// Load YAML config and apply to process.env (before other imports)
|
||||
// Load YAML config and apply to process.env (overrides .env values)
|
||||
import { loadConfig, applyConfigToEnv, syncProviders, resolveConfigPath } from './config/index.js';
|
||||
const yamlConfig = loadConfig();
|
||||
console.log(`[Config] Loaded from ${resolveConfigPath()}`);
|
||||
|
||||
Reference in New Issue
Block a user