fix: ensure newline separator when appending to files#396
Open
Ktsierra wants to merge 1 commit intoTanStack:mainfrom
Open
fix: ensure newline separator when appending to files#396Ktsierra wants to merge 1 commit intoTanStack:mainfrom
Ktsierra wants to merge 1 commit intoTanStack:mainfrom
Conversation
appendFile concatenated content without checking for a trailing newline, causing malformed output when multiple add-ons append to the same file (e.g. .env.local with sentry + posthog). Add newline guard in both fs and memfs appendFile implementations. Fix 4 .append files missing trailing newlines (sentry, strapi, mcp).
There was a problem hiding this comment.
Pull request overview
This PR fixes a content concatenation issue where multiple add-ons appending to the same file (e.g., .env.local) would have their content directly concatenated without proper separation. The fix ensures proper formatting by automatically inserting blank line separators between appended sections.
Changes:
- Modified
appendFileimplementations in both real fs and memfs to automatically add a blank line separator when appending to existing files - Added missing trailing newlines to 4
.appendtemplate files (Sentry, Strapi for React and Solid, MCP gitignore) - Updated test assertions to reflect the new blank-line separator behavior
Reviewed changes
Copilot reviewed 4 out of 8 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| packages/create/src/environment.ts | Added logic to automatically insert blank line separators (1 or 2 newlines depending on existing content) when appending to files in both real fs and memfs implementations |
| packages/create/src/frameworks/react/add-ons/sentry/assets/_dot_env.local.append | Added missing trailing newline to Sentry environment config |
| packages/create/src/frameworks/react/add-ons/strapi/assets/_dot_env.local.append | Added missing trailing newline to Strapi environment config for React |
| packages/create/src/frameworks/solid/add-ons/strapi/assets/_dot_env.local.append | Added missing trailing newline to Strapi environment config for Solid |
| packages/create/src/frameworks/react/add-ons/mcp/assets/_dot_gitignore.append | Added missing trailing newline to MCP gitignore |
| packages/create/tests/template-file.test.ts | Updated test assertion to expect blank line separator between appended content |
| packages/create/tests/filename-processing.test.ts | Updated test assertion to account for the blank line separator behavior |
| packages/create/tests/environment.test.ts | Updated test assertion to verify blank line separator in appendFile operations |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
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
.env.local), the content fromthe second add-on gets concatenated directly onto the last line of the first add-on's
content if it doesn't end with a newline. For example, selecting both Sentry and PostHog
produces
SENTRY_AUTH_TOKEN=# PostHog configuration...instead of two separate lines.appendFileimplementations thatensures a blank line between appended sections for readability.
.appendfiles: Sentry (react), Strapi (react + solid),and MCP gitignore (react).
Test plan
pnpm buildpassespnpm testpasses (271 tests across 3 packages)node ./cli/packages/cli/dist/bin.js create test-app --framework react --add-ons sentry,posthogproduces a valid.env.localwith eachadd-on's variables separated by a blank line