| 257 | } |
| 258 | |
| 259 | function readEnvFile(filePath) { |
| 260 | if (!existsSync(filePath)) { |
| 261 | return {}; |
| 262 | } |
| 263 | const result = {}; |
| 264 | for (const line of readFileSync(filePath, "utf8").split(/\r?\n/)) { |
| 265 | const trimmed = line.trim(); |
| 266 | if (!trimmed || trimmed.startsWith("#")) { |
| 267 | continue; |
| 268 | } |
| 269 | const separatorIndex = trimmed.indexOf("="); |
| 270 | if (separatorIndex <= 0) { |
| 271 | continue; |
| 272 | } |
| 273 | const rawKey = trimmed.slice(0, separatorIndex).trim(); |
| 274 | const key = rawKey.startsWith("export ") ? rawKey.slice("export ".length).trim() : rawKey; |
| 275 | let value = trimmed.slice(separatorIndex + 1).trim(); |
| 276 | if ((value.startsWith("\"") && value.endsWith("\"")) || (value.startsWith("'") && value.endsWith("'"))) { |
| 277 | value = value.slice(1, -1); |
| 278 | } |
| 279 | result[key] = value; |
| 280 | } |
| 281 | return result; |
| 282 | } |
| 283 | |
| 284 | function findRepositoryRoot() { |
| 285 | let current = dirname(fileURLToPath(import.meta.url)); |