Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a feature for overwriting the whole output file #32

Merged
merged 3 commits into from
Jul 29, 2023

Conversation

imgrant
Copy link
Contributor

@imgrant imgrant commented Jul 13, 2023

This PR adds an out option, consumeWholeFile (boolean, default: false), which can be used with plain output type files to simply always overwrite the whole file with the new version number, rather that doing a search-and-replace operation with the existing contents (the current behaviour).

This can be useful when the output file cannot be guaranteed to be up-to-date (i.e. contain the matching latest version). It also goes some way to matching the behaviour of structured output files such as JSON — e.g. the new version is always written to the { "version" } field in package.json, regardless of whether the existing { "version": "<value>" } matches that latest version or not.

One caveat is that version number prefixes are not retained, e.g. if plain output file VERSION contains v1.0.0, a patch release would replace it with 1.0.1 (no v prefix). This replicates the behaviour when the output file does not exist at all — current behaviour there is that bumper writes the new version number to the file, sans prefix.

Fixes #31

@webpro webpro merged commit 78e686b into release-it:master Jul 29, 2023
9 checks passed
@webpro
Copy link
Contributor

webpro commented Jul 29, 2023

🚀 This pull request is included in v5.1.0. See Release 5.1.0 for release notes.

@webpro
Copy link
Contributor

webpro commented Jul 29, 2023

Thanks @imgrant! Even though there's a simple(r) solution to writing the version to a file, I agree it's nice to keep config together.

@imgrant
Copy link
Contributor Author

imgrant commented Jul 29, 2023

Excellent, glad to see it merged. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Plain text file out does not replace outdated version numbers
2 participants