Add a feature for overwriting the whole output file #32
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 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 inpackage.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
containsv1.0.0
, a patch release would replace it with1.0.1
(nov
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