kokoirc 0.2.0 → 0.2.2
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/README.md +1 -1
- package/package.json +1 -1
- package/src/core/config/loader.ts +16 -0
package/README.md
CHANGED
|
@@ -146,7 +146,7 @@ Format codes: `%r` red, `%g` green, `%ZRRGGBB` hex color, `%_` bold, `%u` underl
|
|
|
146
146
|
Scripts are TypeScript files loaded from `~/.kokoirc/scripts/`. See `examples/scripts/` for samples.
|
|
147
147
|
|
|
148
148
|
```typescript
|
|
149
|
-
import type { KokoAPI } from "kokoirc
|
|
149
|
+
import type { KokoAPI } from "kokoirc/api"
|
|
150
150
|
|
|
151
151
|
export default function slap(api: KokoAPI) {
|
|
152
152
|
api.command("slap", ({ args, buffer }) => {
|
package/package.json
CHANGED
|
@@ -80,6 +80,22 @@ export async function loadConfig(configPath: string): Promise<AppConfig> {
|
|
|
80
80
|
const text = await file.text()
|
|
81
81
|
const parsed = parseTOML(text)
|
|
82
82
|
const config = mergeWithDefaults(parsed)
|
|
83
|
+
|
|
84
|
+
// Load ~/.kokoirc/.env into process.env (Bun only auto-loads cwd/.env)
|
|
85
|
+
const envFile = Bun.file(ENV_PATH)
|
|
86
|
+
if (await envFile.exists()) {
|
|
87
|
+
const envText = await envFile.text()
|
|
88
|
+
for (const line of envText.split("\n")) {
|
|
89
|
+
const trimmed = line.trim()
|
|
90
|
+
if (!trimmed || trimmed.startsWith("#")) continue
|
|
91
|
+
const eqIdx = trimmed.indexOf("=")
|
|
92
|
+
if (eqIdx === -1) continue
|
|
93
|
+
const key = trimmed.slice(0, eqIdx).trim()
|
|
94
|
+
const value = trimmed.slice(eqIdx + 1).trim()
|
|
95
|
+
if (key) process.env[key] = value
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
|
|
83
99
|
config.servers = loadCredentials(config.servers, process.env)
|
|
84
100
|
return config
|
|
85
101
|
}
|