MCPcopy Create free account
hub / github.com/HKUDS/AgentSpace / readEnvFile

Function readEnvFile

scripts/feishu/run-db-tests.mjs:259–282  ·  view source on GitHub ↗
(filePath)

Source from the content-addressed store, hash-verified

257}
258
259function 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
284function findRepositoryRoot() {
285 let current = dirname(fileURLToPath(import.meta.url));

Callers 1

deleteNeonBranchFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected