Skip to content

AI-native knowledge base & Evernote/Obsidian alternative with instant sync & native MCP. Free on Cloudflare or self-hosted via Docker.

fix: preserve password hashes in Bun env loading

yoma5d2808f19aed
diff --git a/scripts/cloudflare-deploy.mjs b/scripts/cloudflare-deploy.mjs
index 4fa1abc1..728f4208 100644
--- a/scripts/cloudflare-deploy.mjs
+++ b/scripts/cloudflare-deploy.mjs
@@ -44,6 +44,9 @@ const parseEnv = (content) => {
) {
value = value.slice(1, -1);
}
+ // Bun expands $ references while auto-loading .env files. Values written
+ // by this script escape literal dollars as \$ so they survive that load.
+ value = value.replace(/\\\$/g, "$");
values.set(key, value);
}
@@ -86,10 +89,12 @@ const targetKey = (name, values) => scopedKey(name, values) || `EDGE_EVER_${name
const upsertEnv = (key, value) => {
const content = existsSync(envPath) ? readFileSync(envPath, "utf8") : "";
+ // Keep literal dollars from being expanded by Bun when it auto-loads the file.
+ const fileValue = value.replace(/\$/g, "\\$");
const pattern = new RegExp(`^${key.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")}=.*$`, "m");
const next = pattern.test(content)
- ? content.replace(pattern, `${key}=${value}`)
- : `${content.trimEnd()}\n${key}=${value}\n`;
+ ? content.replace(pattern, () => `${key}=${fileValue}`)
+ : `${content.trimEnd()}\n${key}=${fileValue}\n`;
writeFileSync(envPath, next.startsWith("\n") ? next.slice(1) : next);
process.env[key] = value;
diff --git a/scripts/run-wrangler.mjs b/scripts/run-wrangler.mjs
index 54098537..71f0a3c9 100644
--- a/scripts/run-wrangler.mjs
+++ b/scripts/run-wrangler.mjs
@@ -35,6 +35,10 @@ const loadLocalEnv = () => {
value = value.slice(1, -1);
}
+ // Bun expands $ references while auto-loading .env files. Values written
+ // by the deployment script escape literal dollars as \$.
+ value = value.replace(/\\\$/g, "$");
+
if (key) {
process.env[key] = value;
}