version-bump-prompt icon indicating copy to clipboard operation
version-bump-prompt copied to clipboard

Update version in text file via regex or other means

Open Svenito opened this issue 5 years ago • 2 comments

If you have a changelog file or similar, it would be helpful to specify a next or other named field that will be replaced by the new bumped version.

Possibly configurable via a local config file maybe, or a predefined value like next.

Svenito avatar Jan 13 '20 09:01 Svenito

If I understand your needs correctly, I believe you can already do that. There are a couple ways...

Option 1 - Replace old version with new version

You can specify any type of file for version-bump-prompt to bump, including text files, config files, ReadMe files, etc. It will find and replace all occurrences of the old version number with the new version number in those files.

For example, to bump the version number in your package.json and package-lock.json as well your ReadMe file and all text files, you'd run this command:

bump package.json package-lock.json ReadMe.md *.txt

See the ReadMe for more details.

Option 2 - Use a postversion script

version-bump-prompt supports npm version scripts, such as preversion, version, and postversion. In your case, you could write a postversion script that replaces whatever placeholder you want with the new version number.

See the ReadMe for more details.

JamesMessinger avatar Jan 13 '20 10:01 JamesMessinger

The postversion script seems most suitable for what I'd like to do. The first option only works to replace the old version, which wouldn't be ideal for a changelog file.

Thanks. I'll give the second option a go

Svenito avatar Jan 13 '20 10:01 Svenito