grunt-version
grunt-version copied to clipboard
Version bumping acting weird
I have the following config:
version: {
default: {
options: {
prefix: 'widget version="'
},
src: ['config.xml']
}
}
When executing the task passing "minor/major/patch", weird things happen (at least with minor and patch). Following is an example of consecutive calls to the task:
$ grunt version::2.1.0
Running "version:default:2.1.0" (version) task
File updated.
Path: config.xml
Old version: 1.1.0. New version: 2.1.0.
Done, without errors.
$ grunt version::patch
Running "version:default:patch" (version) task
File updated.
Path: config.xml
Old version: 2.1.0. New version: 1.0.1.
Done, without errors.
$ grunt version::major
Running "version:default:major" (version) task
File updated.
Path: config.xml
Old version: 1.0.1. New version: 2.0.0.
Done, without errors.
$ grunt version::minor
Running "version:default:minor" (version) task
File updated.
Path: config.xml
Old version: 2.0.0. New version: 1.1.0.
Done, without errors.
I am using Windows 8.1, and the config.xml line that I want to change is like this one:
<widget version="1.1.0" id="myappId">
Is a config.xml file for a cordova app. Explicit version syntax works without problem.
Cheers!
Hi @EvilJohnny . I think the problem is that you're not updating the package.json file's version. By default, grunt-version uses that file for the "canonical" version. If you don't care about keeping the package.json file in sync with config.xml, you could just do this:
Edit: this code won't work (see next comment):
// ...
version: {
default: {
options: {
pkg: 'config.xml',
prefix: 'widget version="'
},
src: ['config.xml']
}
}
// ...
I'd recommend updating it, though. You can do it this way:
// ...
version: {
package: {
src: ['package.json']
},
default: {
options: {
prefix: 'widget version="'
},
src: ['config.xml']
}
}
// ...
Sorry, sent previous comment too soon. That first suggestion won't work. the pkg
option has to refer to either a JSON file or a JavaScript object.
@kswedberg I am using the exact same pattern (for a cordova app). I ended up using the last snippet you posted and it worked perfectly. Given this, you can probably close this issue.
Hey sorry guys, I didn't had the chance to look at this. My notebook fried itself inside a bag, and after solving the mess I didn't work at the project I was doing the tests with.
The project was also a Cordova app, so @kswedberg, if @jimthedev says it works, surely it will work for me too. Thanks for everything and again apologies for not coming back to this issue :flushed: !
@EvilJohnny No worries. We all get busy. You can also close the issue if you're confident that it will work for you. ;)
Thanks to both of you, @EvilJohnny and @jimthedev. I think I'll keep this open until I get a chance to mention something about it in the readme.
Thanks! It might also be worth mentioning that you almost always want your package.json to be your last target definition since when you do grunt version::patch it will give odd results if you have package.json getting bumped first. Caused me some confusion since package.json is re-read for each target in the series.