-
Notifications
You must be signed in to change notification settings - Fork 122
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(bump all files): add support for prerelase
Upgrade semve to allow for prerelease versions Change RexExp for versions and prerelease versions Add prereleaseName to options, defaulted to null - pre release types: named: 1.0.0-rc.0 unnamed: 1.0.0-0 Fix issue where bump:git on multiple files failed Closes: 42, 94, 102, 110
- Loading branch information
Showing
3 changed files
with
80 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,6 +6,10 @@ | |
* grunt bump:patch | ||
* grunt bump:minor | ||
* grunt bump:major | ||
* grunt bump:prepatch | ||
* grunt bump:preminor | ||
* grunt bump:premajor | ||
* grunt bump:prerelease | ||
* | ||
* @author Vojta Jina <[email protected]> | ||
* @author Mathias Paumgarten <[email protected]> | ||
|
@@ -34,7 +38,8 @@ module.exports = function(grunt) { | |
push: true, | ||
pushTo: 'upstream', | ||
gitDescribeOptions: '--tags --always --abbrev=1 --dirty=-d', | ||
globalReplace: false | ||
globalReplace: false, | ||
prereleaseName: null | ||
}); | ||
|
||
var dryRun = grunt.option('dry-run'); | ||
|
@@ -77,14 +82,12 @@ module.exports = function(grunt) { | |
|
||
var globalVersion; // when bumping multiple files | ||
var gitVersion; // when bumping using `git describe` | ||
var VERSION_REGEXP = /([\'|\"]?version[\'|\"]?[ ]*:[ ]*[\'|\"]?)([\d||A-a|.|-]*)([\'|\"]?)/i; | ||
|
||
var VERSION_REGEXP = new RegExp('([\\\'|\\\"]?version[\\\'|\\\"]?[ ]*:[ ]*[\\\'|\\\"]?)(\\\d+\\\.\\\d+\\\.\\\d+(-'+opts.prereleaseName+'\\\.\\\d+)?(-\\\d+)?)[\\\d||A-a|.|-]*([\\\'|\\\"]?)', 'i'); | ||
|
||
if (opts.globalReplace) { | ||
VERSION_REGEXP = new RegExp(VERSION_REGEXP.source, 'gi'); | ||
} | ||
|
||
|
||
// GET VERSION FROM GIT | ||
runIf(opts.bumpVersion && versionType === 'git', function() { | ||
exec('git describe ' + opts.gitDescribeOptions, function(err, stdout) { | ||
|
@@ -96,14 +99,13 @@ module.exports = function(grunt) { | |
}); | ||
}); | ||
|
||
|
||
// BUMP ALL FILES | ||
runIf(opts.bumpVersion, function() { | ||
grunt.file.expand(opts.files).forEach(function(file, idx) { | ||
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'); | ||
var bumpFrom; | ||
var content = grunt.file.read(file).replace(VERSION_REGEXP, function(match, prefix, parsedVersion, namedPre, noNamePre, suffix) { | ||
version = exactVersionToSet || gitVersion || semver.inc(parsedVersion, versionType || 'patch', opts.prereleaseName); | ||
return prefix + version + suffix; | ||
}); | ||
|
||
|