Skip to content

Commit 0cd85ef

Browse files
committed
feat: load environment variables from .env file and add @libsql/client dependency
1 parent 47e529f commit 0cd85ef

File tree

3 files changed

+19
-0
lines changed

3 files changed

+19
-0
lines changed

objectstack.config.ts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,21 @@
88

99
import { createRequire } from 'module';
1010
import * as path from 'path';
11+
import * as fs from 'fs';
12+
13+
// Load .env file into process.env (zero-dependency, Node-native approach)
14+
const envPath = path.resolve(path.dirname(new URL(import.meta.url).pathname), '.env');
15+
if (fs.existsSync(envPath)) {
16+
for (const line of fs.readFileSync(envPath, 'utf-8').split('\n')) {
17+
const trimmed = line.trim();
18+
if (!trimmed || trimmed.startsWith('#')) continue;
19+
const eqIdx = trimmed.indexOf('=');
20+
if (eqIdx === -1) continue;
21+
const key = trimmed.slice(0, eqIdx).trim();
22+
const val = trimmed.slice(eqIdx + 1).trim();
23+
if (!process.env[key]) process.env[key] = val;
24+
}
25+
}
1126

1227
// Polyfill require and __dirname for ESM
1328
if (typeof globalThis.require === 'undefined') {

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@
6767
},
6868
"version": "4.2.0",
6969
"dependencies": {
70+
"@libsql/client": "^0.17.2",
7071
"@objectql/protocol-json-rpc": "workspace:*",
7172
"@objectstack/studio": "^3.2.8",
7273
"build": "^0.1.4"

pnpm-lock.yaml

Lines changed: 3 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)