MCPcopy Create free account
hub / github.com/clockworklabs/SpacetimeDB / parseEnvFile

Function parseEnvFile

templates/angular-ts/scripts/dev.mjs:13–25  ·  view source on GitHub ↗

Parse a .env file into a key-value object.

(filePath)

Source from the content-addressed store, hash-verified

11
12/** Parse a .env file into a key-value object. */
13function parseEnvFile(filePath) {
14 const vars = {};
15 if (!existsSync(filePath)) return vars;
16
17 for (const line of readFileSync(filePath, 'utf-8').split('\n')) {
18 const trimmed = line.trim();
19 if (!trimmed || trimmed.startsWith('#')) continue;
20 const eqIdx = trimmed.indexOf('=');
21 if (eqIdx === -1) continue;
22 vars[trimmed.slice(0, eqIdx)] = trimmed.slice(eqIdx + 1);
23 }
24 return vars;
25}
26
27const envFile = parseEnvFile('.env.local');
28

Callers 1

dev.mjsFile · 0.85

Calls 1

splitMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…