mirror of
https://github.com/bknd-io/bknd/
synced 2026-08-02 08:06:00 +00:00
fix(cli): detect bun: protocol imports and re-exec under Bun
Catch ERR_UNSUPPORTED_ESM_URL_SCHEME with bun: protocol in addition to ReferenceError "Bun is not defined" when deciding to re-exec. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -179,10 +179,11 @@ export async function makeAppFromEnv(options: Partial<RunOptions> = {}) {
|
||||
try {
|
||||
const config = await loadConfigFile(configFilePath);
|
||||
app = await makeConfigApp(config, options.server);
|
||||
} catch (e) {
|
||||
if (e instanceof ReferenceError && /\bBun\b.*not defined/.test(e.message)) {
|
||||
reexecUnderBun();
|
||||
}
|
||||
} catch (e: any) {
|
||||
const needsBun =
|
||||
(e instanceof ReferenceError && /\bBun\b.*not defined/.test(e.message)) ||
|
||||
(e?.code === "ERR_UNSUPPORTED_ESM_URL_SCHEME" && /bun:/.test(e.message));
|
||||
if (needsBun) reexecUnderBun();
|
||||
console.error("Failed to load config:", e);
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user