@mantiq/core 0.4.0-rc.2 → 0.5.0
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
CHANGED
|
@@ -47,6 +47,7 @@ export class Application extends ContainerImpl {
|
|
|
47
47
|
configPath: string = 'config',
|
|
48
48
|
): Promise<Application> {
|
|
49
49
|
const app = new Application(basePath)
|
|
50
|
+
await app.loadEnv()
|
|
50
51
|
await app.loadConfig(configPath)
|
|
51
52
|
Application._instance = app
|
|
52
53
|
return app
|
|
@@ -79,6 +80,32 @@ export class Application extends ContainerImpl {
|
|
|
79
80
|
Application._instance = null
|
|
80
81
|
}
|
|
81
82
|
|
|
83
|
+
// ── Environment ─────────────────────────────────────────────────────────
|
|
84
|
+
|
|
85
|
+
/**
|
|
86
|
+
* Load .env file from the base path.
|
|
87
|
+
* Variables are only set if not already present in process.env.
|
|
88
|
+
*/
|
|
89
|
+
private async loadEnv(): Promise<void> {
|
|
90
|
+
const envFile = Bun.file(this.basePath + '/.env')
|
|
91
|
+
try {
|
|
92
|
+
if (await envFile.exists()) {
|
|
93
|
+
const text = await envFile.text()
|
|
94
|
+
for (const line of text.split('\n')) {
|
|
95
|
+
const trimmed = line.trim()
|
|
96
|
+
if (!trimmed || trimmed.startsWith('#')) continue
|
|
97
|
+
const eqIdx = trimmed.indexOf('=')
|
|
98
|
+
if (eqIdx === -1) continue
|
|
99
|
+
const key = trimmed.slice(0, eqIdx).trim()
|
|
100
|
+
const value = trimmed.slice(eqIdx + 1).trim()
|
|
101
|
+
if (key && !(key in process.env)) process.env[key] = value
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
} catch {
|
|
105
|
+
// .env file doesn't exist or can't be read — that's fine
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
|
|
82
109
|
// ── Config ────────────────────────────────────────────────────────────────
|
|
83
110
|
|
|
84
111
|
/**
|