Align CLI dotenv parsing with the runtime - #158
Open
salluexez wants to merge 1 commit into
Open
Conversation
There was a problem hiding this comment.
Pull request overview
This PR updates the CLI’s .env parsing to more closely match Node’s --env-file behavior by recognizing export -prefixed assignments and stripping matching outer quotes from values, and adjusts unit tests accordingly.
Changes:
- Extend
readEnvFileto acceptexport KEY=...lines. - Strip matching outer single/double quotes from parsed values.
- Update
cli/test/util.test.tsto coverexportprefix and quoted values.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
cli/src/util.ts |
Enhances readEnvFile parsing (export-prefix support, quote stripping). |
cli/test/util.test.ts |
Updates/expands env parsing test coverage for the new parsing rules. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+220
to
223
| let line = raw.trim(); | ||
| if (!line || line.startsWith("#")) continue; | ||
| if (line.startsWith("export ")) line = line.slice(7).trimStart(); | ||
| const eq = line.indexOf("="); |
Comment on lines
+227
to
+231
| let val = line.slice(eq + 1).trim(); | ||
| if ((val.startsWith('"') && val.endsWith('"')) || (val.startsWith("'") && val.endsWith("'"))) { | ||
| val = val.slice(1, -1); | ||
| } | ||
| out.set(key, val); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Align
readEnvFileincli/src/util.tswith Node.js--env-fileruntime parsing rules by supporting optionalexportline prefixes and stripping matching outer double or single quotes around values. Includes unit test updates incli/test/util.test.ts.Need help on this PR? Tag
@codesmith-botwith what you need. Autofix is disabled.