Skip to content

Commit

Permalink
feat: allow a version # to be provided for release-as, rather than ju…
Browse files Browse the repository at this point in the history
…st major, minor, patch.
  • Loading branch information
stevemao authored and bcoe committed May 27, 2017
1 parent 0d1fb38 commit 13eb9cd
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 2 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,8 @@ you would like your next release to be a `minor`. Simply do:
```bash
# npm run script
npm run release -- --release-as minor
# Or
npm run release -- --release-as 1.1.0
```

you will get version `1.1.0` rather than the auto generated version `1.0.1`.
Expand Down
1 change: 0 additions & 1 deletion command.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ module.exports = require('yargs')
describe: 'Specify the release type manually (like npm version <major|minor|patch>)',
requiresArg: true,
string: true,
choices: ['major', 'minor', 'patch'],
global: true
})
.option('prerelease', {
Expand Down
2 changes: 1 addition & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ module.exports = function standardVersion (argv, done) {

if (!args.firstRelease) {
var releaseType = getReleaseType(args.prerelease, release.releaseType, pkg.version)
newVersion = semver.inc(pkg.version, releaseType, args.prerelease)
newVersion = semver.valid(releaseType) || semver.inc(pkg.version, releaseType, args.prerelease)
updateConfigs(args, newVersion)
} else {
checkpoint(args, 'skip version bump on first release', [], chalk.red(figures.cross))
Expand Down
28 changes: 28 additions & 0 deletions test.js
Original file line number Diff line number Diff line change
Expand Up @@ -290,6 +290,34 @@ describe('cli', function () {
})
})

describe('release-as-exact', function () {
it('releases as v100.0.0', function () {
var originVer = '1.0.0'
writePackageJson(originVer)
fs.writeFileSync('CHANGELOG.md', 'legacy header format<a name="1.0.0">\n', 'utf-8')

commit('fix: first commit')

return execCliAsync('--release-as v100.0.0')
.then(function () {
getPackageVersion().should.equal('100.0.0')
})
})

it('releases as 200.0.0-amazing', function () {
var originVer = '1.0.0'
writePackageJson(originVer)
fs.writeFileSync('CHANGELOG.md', 'legacy header format<a name="1.0.0">\n', 'utf-8')

commit('fix: first commit')

return execCliAsync('--release-as 200.0.0-amazing')
.then(function () {
getPackageVersion().should.equal('200.0.0-amazing')
})
})
})

it('creates a prerelease with a new minor version after two prerelease patches', function () {
writePackageJson('1.0.0')
fs.writeFileSync('CHANGELOG.md', 'legacy header format<a name="1.0.0">\n', 'utf-8')
Expand Down

0 comments on commit 13eb9cd

Please sign in to comment.