MCPcopy Create free account
hub / github.com/Gan-Xing/CodexBridge / parseEnvText

Function parseEnvText

packages/codex-native-api/src/daemon_manager.ts:979–1004  ·  view source on GitHub ↗
(content: string)

Source from the content-addressed store, hash-verified

977}
978
979function parseEnvText(content: string): Record<string, string> {
980 const record: Record<string, string> = {};
981 content.split(/\r?\n/u).forEach((rawLine) => {
982 const line = rawLine.trim();
983 if (!line || line.startsWith('#')) {
984 return;
985 }
986 const separatorIndex = line.indexOf('=');
987 if (separatorIndex <= 0) {
988 return;
989 }
990 const key = line.slice(0, separatorIndex).trim();
991 let value = line.slice(separatorIndex + 1).trim();
992 if (!/^[A-Za-z_][A-Za-z0-9_]*$/u.test(key)) {
993 return;
994 }
995 if (
996 (value.startsWith('"') && value.endsWith('"'))
997 || (value.startsWith("'") && value.endsWith("'"))
998 ) {
999 value = value.slice(1, -1);
1000 }
1001 record[key] = value;
1002 });
1003 return record;
1004}
1005
1006async function runCommand(
1007 command: string,

Callers 1

readEnvFileRecordFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected