(key: string, value: string)
| 162 | } |
| 163 | |
| 164 | export const upsertEnvValue = (key: string, value: string): void => { |
| 165 | const envPath = getEnvFilePath() |
| 166 | const { lines, parsed } = parseEnvFile() |
| 167 | |
| 168 | const existing = parsed.find((line) => line.key === key) |
| 169 | const replacement = `${key}=${value}` |
| 170 | |
| 171 | if (existing) { |
| 172 | lines[existing.index] = replacement |
| 173 | } else { |
| 174 | if (lines.length > 0 && lines[lines.length - 1].trim() !== '') { |
| 175 | lines.push('') |
| 176 | } |
| 177 | lines.push(replacement) |
| 178 | } |
| 179 | |
| 180 | fs.writeFileSync(envPath, lines.join('\n').replace(/\n?$/, '\n'), 'utf-8') |
| 181 | } |
| 182 | |
| 183 | export const validateEnvValues = (values: Record<string, string>): EnvValidationIssue[] => { |
| 184 | const issues: EnvValidationIssue[] = [] |
no test coverage detected