conventional-recommended-version
Advanced tools
Comparing version 0.1.1 to 0.2.0
@@ -0,3 +1,13 @@ | ||
<a name="0.2.0"></a> | ||
# [0.2.0](https://github.com/JamieMason/conventional-recommended-version/compare/0.1.1...v0.2.0) (2015-12-01) | ||
### Features | ||
* **api:** create nodejs api ([8cf496e](https://github.com/JamieMason/conventional-recommended-version/commit/8cf496e)) | ||
<a name="0.1.1"></a> | ||
## [0.1.1](https://github.com/JamieMason/conventional-recommended-version/compare/0.1.0...v0.1.1) (2015-11-30) | ||
## [0.1.1](https://github.com/JamieMason/conventional-recommended-version/compare/0.1.0...0.1.1) (2015-11-30) | ||
@@ -4,0 +14,0 @@ |
65
cli.js
@@ -6,7 +6,4 @@ #!/usr/bin/env node | ||
var program = require('commander'); | ||
var gitlog = require('gitlog'); | ||
var pkg = require('./package.json'); | ||
var breaking = 0; | ||
var feat = 0; | ||
var fix = 0; | ||
var crv = require('./index'); | ||
@@ -19,58 +16,12 @@ program | ||
if (program.postfix) { | ||
program.postfix = '-' + program.postfix; | ||
} | ||
crv.get({ | ||
directory: program.directory, | ||
postfix: program.postfix | ||
}, onVersion); | ||
gitlog({ | ||
fields: ['subject', 'body'], | ||
number: 9000 * 1000 * 1000, | ||
repo: program.directory | ||
}, parseGitHistory); | ||
function parseGitHistory(error, commits) { | ||
if (!error) { | ||
commits.reverse().forEach(parseCommit); | ||
console.log(breaking + '.' + feat + '.' + fix + program.postfix); | ||
} else { | ||
function onVersion(error, version) { | ||
if (error) { | ||
throw error; | ||
} | ||
console.log(version); | ||
} | ||
function parseCommit(commit) { | ||
parseBreakingChange(commit); | ||
parseFeature(commit); | ||
parseFix(commit); | ||
} | ||
function parseBreakingChange(commit) { | ||
if (isBreakingChange(commit)) { | ||
breaking++; | ||
feat = 0; | ||
fix = 0; | ||
} | ||
} | ||
function parseFeature(commit) { | ||
if (isFeature(commit)) { | ||
feat++; | ||
fix = 0; | ||
} | ||
} | ||
function parseFix(commit) { | ||
if (isFix(commit)) { | ||
fix++; | ||
} | ||
} | ||
function isFeature(commit) { | ||
return commit.body.search(/^feat\(/) !== -1; | ||
} | ||
function isFix(commit) { | ||
return commit.body.search(/^fix\(/) !== -1; | ||
} | ||
function isBreakingChange(commit) { | ||
return commit.body.search(/BREAKING CHANGE/) !== -1; | ||
} |
{ | ||
"name": "conventional-recommended-version", | ||
"description": "Using a conventional-changelog commit history, determine the current version number of your project.", | ||
"version": "0.1.1", | ||
"version": "0.2.0", | ||
"author": "Jamie Mason <siunmaru@gmail.com>", | ||
@@ -37,2 +37,3 @@ "bin": "cli.js", | ||
"license": "MIT", | ||
"main": "index.js", | ||
"repository": { | ||
@@ -39,0 +40,0 @@ "type": "git", |
7293
7
77