Skip to content

Commit 574f30b

Browse files
committed
fix(config): replace Bun.file() with node:fs/promises for Node.js compatibility
- replace Bun.file() with readFile from node:fs/promises in loadConfig() - ensure configuration loading works in Node.js environment when using bunx - improve error handling comment to clarify file not found and parse errors
1 parent 0dd020a commit 574f30b

File tree

2 files changed

+13
-5
lines changed

2 files changed

+13
-5
lines changed

.changeset/long-brooms-sniff.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
---
2+
"e2sm": patch
3+
---
4+
5+
fix(config): replace Bun.file() with node:fs/promises for Node.js compatibility
6+
7+
- replace Bun.file() with readFile from node:fs/promises in loadConfig()
8+
- ensure configuration loading works in Node.js environment when using bunx
9+
- improve error handling comment to clarify file not found and parse errors

src/lib.ts

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -135,17 +135,16 @@ export interface E2smConfig {
135135
export async function loadConfig(): Promise<E2smConfig> {
136136
const { homedir } = await import("node:os");
137137
const { join } = await import("node:path");
138+
const { readFile } = await import("node:fs/promises");
138139

139140
const candidates = [join(process.cwd(), ".e2smrc.json"), join(homedir(), ".e2smrc.json")];
140141

141142
for (const filePath of candidates) {
142143
try {
143-
const file = Bun.file(filePath);
144-
if (await file.exists()) {
145-
return await file.json();
146-
}
144+
const content = await readFile(filePath, "utf-8");
145+
return JSON.parse(content);
147146
} catch {
148-
// ignore parse errors, continue to next
147+
// ignore errors (file not found, parse errors), continue to next
149148
}
150149
}
151150

0 commit comments

Comments
 (0)