fix(env): read empty .env values as unset instead of the next line - #236
jamie-at-bunny wants to merge 11 commits into
Conversation
🦋 Changeset detectedLatest commit: e480210 The changes in this PR will be included in the next version bump. This PR includes changesets to release 6 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
|
@codex review |
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 4326660f24
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
…es on write/remove
…ite new keys above them
| } else if (unterminated[0]) { | ||
| lines.splice(unterminated[0].start, 0, line); | ||
| writeFileSync(target, lines.join("\n"), "utf-8"); |
There was a problem hiding this comment.
Old token becomes active again If an unclosed quote hides an existing token line, this branch inserts the replacement above the quote but leaves the old line in place. If the user repairs the quote at its opening line, the old token becomes a later definition and wins, silently undoing the replacement.
Knowledge Base Used: CLI database commands
…-token are both given
Fixes
readEnvValueso an empty line likeBUNNY_DATABASE_URL=counts as unset instead of returning the next line.Why
The old regex,
^KEY\s*=\s*["']?(.+?)["']?\s*$with themflag, let\s*match the newline. So on an empty value it read the following line (for exampleBUNNY_DATABASE_AUTH_TOKEN=) as the value. That is why database.env.examplefiles have had to comment those lines out.What changed
readEnvValuenow usesparseEnvFile, the shared dotenv parser already imported inutils/env-file.ts, in place of the regex. It still walks up parent directories, and an empty value still counts as unset.@bunny.net/cli.Reviewer notes
The parser changes three other behaviours slightly:
KEY=val # devreads asval).export KEY=...lines are now found.🤖 Generated with Claude Code