sonar / sonar (push) Skipped
sonar / sonar (pull_request) Failing after 40s
Enable local workshop readiness with executable SQLite migrations, OpenTelemetry hello signals, and a provisioned Grafana demo dashboard over Tempo/Loki/Prometheus. Co-authored-by: Cursor <cursoragent@cursor.com>
21 lines
679 B
TypeScript
21 lines
679 B
TypeScript
import { readFileSync } from "node:fs";
|
|
import { join } from "node:path";
|
|
|
|
/** Load `.env` into process.env without overriding existing vars. */
|
|
export function loadDotEnv(cwd = process.cwd()): void {
|
|
try {
|
|
const text = readFileSync(join(cwd, ".env"), "utf8");
|
|
for (const line of text.split(/\r?\n/)) {
|
|
const trimmed = line.trim();
|
|
if (!trimmed || trimmed.startsWith("#")) continue;
|
|
const i = trimmed.indexOf("=");
|
|
if (i <= 0) continue;
|
|
const key = trimmed.slice(0, i).trim();
|
|
const value = trimmed.slice(i + 1).trim();
|
|
if (process.env[key] === undefined) process.env[key] = value;
|
|
}
|
|
} catch {
|
|
// optional .env
|
|
}
|
|
}
|