Add newline to prepended name and compatibility_date in wrangler.toml #5816
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.
This was causing create-cloudflare to generate an incorrect wrangler.toml for templates that didn't include these attributes.
What this PR solves / how to test
When
npm create cloudflare
creates a project, it either updatesname
andcompatibility_date
properties in wrangler.toml, or adds them if they don't exist yet.In that case they are added by prepending to the toml file, but this is done without a new line, which results in a broken toml file.
For example this:
npm create cloudflare@latest my-app -- --template xtuc/img-color-worker
Results in this wrangler.toml:
Apparently in this case the template did have a
name =
, which was updated, but nocompatibility_date =
, so it was prepended to the file but without a new line.The fix is pretty simple, and I've added a line to the corresponding unit test to parse the resulting toml to make sure it's valid.
Your CONTRIBUTING.md says it's ok to open a PR directly for trivial changes. I think this could be considered trivial, but course that depends on your definition. :-)
So if you'd like me to open an issue for this, then please let me know.
Author has addressed the following