codebrief 1.1.6 → 1.1.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/index.js +21 -0
package/package.json
CHANGED
package/src/index.js
CHANGED
|
@@ -19,6 +19,27 @@ const {
|
|
|
19
19
|
getAllProviders,
|
|
20
20
|
} = require("./models");
|
|
21
21
|
|
|
22
|
+
// ── Load env files (no external deps) ────────────────────────
|
|
23
|
+
// Reads KEY=VALUE lines from a file and sets missing process.env vars
|
|
24
|
+
function loadEnvFile(filePath) {
|
|
25
|
+
if (!fs.existsSync(filePath)) return;
|
|
26
|
+
const lines = fs.readFileSync(filePath, "utf-8").split("\n");
|
|
27
|
+
for (const raw of lines) {
|
|
28
|
+
const line = raw.trim();
|
|
29
|
+
if (!line || line.startsWith("#")) continue;
|
|
30
|
+
const eq = line.indexOf("=");
|
|
31
|
+
if (eq === -1) continue;
|
|
32
|
+
const key = line.slice(0, eq).trim();
|
|
33
|
+
const val = line.slice(eq + 1).trim().replace(/^['"]|['"]$/g, "");
|
|
34
|
+
if (key && !(key in process.env)) process.env[key] = val;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
// Priority (lowest → highest): ~/.codebrief → .env → .env.local
|
|
39
|
+
loadEnvFile(path.join(require("os").homedir(), ".codebrief"));
|
|
40
|
+
loadEnvFile(path.join(process.cwd(), ".env"));
|
|
41
|
+
loadEnvFile(path.join(process.cwd(), ".env.local"));
|
|
42
|
+
|
|
22
43
|
// ── Simple CLI argument parser (no dependencies needed) ───────
|
|
23
44
|
const args = process.argv.slice(2);
|
|
24
45
|
|