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

Update version in text file via regex or other means #36

Open
Svenito opened this issue Jan 13, 2020 · 2 comments
Open

Update version in text file via regex or other means #36

Svenito opened this issue Jan 13, 2020 · 2 comments
Labels

Comments

@Svenito
Copy link

Svenito commented Jan 13, 2020

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.

@JamesMessinger
Copy link
Member

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.

@Svenito
Copy link
Author

Svenito commented Jan 13, 2020

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

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

No branches or pull requests

2 participants