server/env_file_helpers.ts view source
(key: string, value: string, options?: UpdateEnvVariableOptions): Promise<void> Updates or adds an environment variable in the .env file. Preserves existing formatting, comments, and other variables.
Behavior:
- Duplicate keys: Updates the LAST occurrence (matches dotenv behavior)
- Inline comments: Preserved after the value (e.g., KEY=value # comment)
- Quote style: Preserved from original (quoted/unquoted)
key
- The environment variable name (e.g., 'SOME_CONFIGURATION_KEY')
stringvalue
- The new value for the environment variable
stringoptions
- Optional configuration for file path and operations
{}returns
Promise<void>