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

feat: Support for prerelease identifiers #102

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,16 @@ $ grunt bump --setversion=2.0.1
>> Pushed to origin
```

If you want to specify an identifier for prerelease versions you can use the ```preid``` tag in the command line.

```bash
$ grunt bump:prerelease --preid dev
>> Version bumped to 2.0.1-dev.0
>> Committed as "Release v2.0.1-dev.0"
>> Tagged as "v2.0.1-dev.0"
>> Pushed to origin
```

Sometimes you want to run another task between bumping the version and committing, for instance generate changelog. You can use `bump-only` and `bump-commit` to achieve that:

```bash
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
},
"license": "MIT",
"dependencies": {
"semver": "~2.3.0"
"semver": "~4.1.0"
},
"peerDependencies": {
"grunt": ">=0.4.0"
Expand Down
4 changes: 3 additions & 1 deletion tasks/bump.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@ module.exports = function(grunt) {
exactVersionToSet = false;
}

var prereleaseIdentifier = grunt.option('preid');
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not fond of preid since its hard to read unless you know what it means. not sure what else to name it though

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I named this to match the command line argument in node-semver

bromanko/node-semver@56258fa#diff-a342e6cbc646e03dc5b605ab42f5f28aR51

If you'd prefer something different I would suggest prereleaseId just let me know and I'll update it.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not sure if preId is better. prereleasePrefix would be nice but its so long


var done = this.async();
var queue = [];
var next = function() {
Expand Down Expand Up @@ -99,7 +101,7 @@ module.exports = function(grunt) {
var version = null;
var content = grunt.file.read(file).replace(VERSION_REGEXP, function(match, prefix, parsedVersion, suffix) {
gitVersion = gitVersion && parsedVersion + '-' + gitVersion;
version = exactVersionToSet || gitVersion || semver.inc(parsedVersion, versionType || 'patch');
version = exactVersionToSet || gitVersion || semver.inc(parsedVersion, versionType || 'patch', false, prereleaseIdentifier);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

that is one long line

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can line break at the ors.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please do

return prefix + version + suffix;
});

Expand Down