conventional-recommended-bump
Advanced tools
Comparing version 2.0.6 to 2.0.7
@@ -6,2 +6,10 @@ # Change Log | ||
<a name="2.0.7"></a> | ||
## [2.0.7](https://github.com/conventional-changelog/conventional-changelog/compare/conventional-recommended-bump@2.0.6...conventional-recommended-bump@2.0.7) (2018-03-22) | ||
**Note:** Version bump only for package conventional-recommended-bump | ||
<a name="2.0.6"></a> | ||
@@ -8,0 +16,0 @@ ## [2.0.6](https://github.com/conventional-changelog/conventional-changelog/compare/conventional-recommended-bump@2.0.5...conventional-recommended-bump@2.0.6) (2018-02-24) |
40
cli.js
#!/usr/bin/env node | ||
'use strict'; | ||
'use strict' | ||
const meow = require(`meow`); | ||
const conventionalRecommendedBump = require(`./`); | ||
const path = require(`path`); | ||
const meow = require(`meow`) | ||
const conventionalRecommendedBump = require(`./`) | ||
const path = require(`path`) | ||
@@ -65,3 +65,3 @@ const cli = meow(` | ||
} | ||
}); | ||
}) | ||
@@ -72,32 +72,32 @@ const options = { | ||
tagPrefix: cli.flags.tagPrefix | ||
}; | ||
const flags = cli.flags; | ||
const preset = flags.preset; | ||
const config = flags.config; | ||
} | ||
const flags = cli.flags | ||
const preset = flags.preset | ||
const config = flags.config | ||
if (preset) { | ||
options.preset = preset; | ||
delete flags.preset; | ||
options.preset = preset | ||
delete flags.preset | ||
} else if (config) { | ||
options.config = require(path.resolve(process.cwd(), config)); | ||
delete flags.config; | ||
options.config = require(path.resolve(process.cwd(), config)) | ||
delete flags.config | ||
} | ||
if (flags.verbose) { | ||
options.warn = console.warn.bind(console); | ||
options.warn = console.warn.bind(console) | ||
} | ||
conventionalRecommendedBump(options, flags, function(err, data) { | ||
conventionalRecommendedBump(options, flags, function (err, data) { | ||
if (err) { | ||
console.error(err.toString()); | ||
process.exit(1); | ||
console.error(err.toString()) | ||
process.exit(1) | ||
} | ||
if (data.releaseType) { | ||
console.log(data.releaseType); | ||
console.log(data.releaseType) | ||
} | ||
if (flags.verbose && data.reason) { | ||
console.log(`Reason: ${data.reason}`); | ||
console.log(`Reason: ${data.reason}`) | ||
} | ||
}); | ||
}) |
90
index.js
@@ -1,33 +0,33 @@ | ||
'use strict'; | ||
const concat = require(`concat-stream`); | ||
const conventionalCommitsFilter = require(`conventional-commits-filter`); | ||
const conventionalCommitsParser = require(`conventional-commits-parser`); | ||
const conventionalChangelogPresetLoader = require(`conventional-changelog-preset-loader`); | ||
const gitSemverTags = require(`git-semver-tags`); | ||
const gitRawCommits = require(`git-raw-commits`); | ||
const presetResolver = require(`./preset-resolver`); | ||
'use strict' | ||
const concat = require(`concat-stream`) | ||
const conventionalCommitsFilter = require(`conventional-commits-filter`) | ||
const conventionalCommitsParser = require(`conventional-commits-parser`) | ||
const conventionalChangelogPresetLoader = require(`conventional-changelog-preset-loader`) | ||
const gitSemverTags = require(`git-semver-tags`) | ||
const gitRawCommits = require(`git-raw-commits`) | ||
const presetResolver = require(`./preset-resolver`) | ||
const VERSIONS = [`major`, `minor`, `patch`]; | ||
const VERSIONS = [`major`, `minor`, `patch`] | ||
module.exports = conventionalRecommendedBump; | ||
module.exports = conventionalRecommendedBump | ||
function conventionalRecommendedBump(optionsArgument, parserOptsArgument, cbArgument) { | ||
function conventionalRecommendedBump (optionsArgument, parserOptsArgument, cbArgument) { | ||
if (typeof optionsArgument !== `object`) { | ||
throw new Error(`The 'options' argument must be an object.`); | ||
throw new Error(`The 'options' argument must be an object.`) | ||
} | ||
const options = Object.assign({ignoreReverted: true}, optionsArgument); | ||
const options = Object.assign({ignoreReverted: true}, optionsArgument) | ||
const cb = typeof parserOptsArgument === `function` ? parserOptsArgument : cbArgument; | ||
const cb = typeof parserOptsArgument === `function` ? parserOptsArgument : cbArgument | ||
if (typeof cb !== `function`) { | ||
throw new Error(`You must provide a callback function.`); | ||
throw new Error(`You must provide a callback function.`) | ||
} | ||
let presetPackage = options.config || {}; | ||
let presetPackage = options.config || {} | ||
if (options.preset) { | ||
try { | ||
presetPackage = conventionalChangelogPresetLoader(options.preset); | ||
presetPackage = conventionalChangelogPresetLoader(options.preset) | ||
} catch (err) { | ||
return cb(new Error(`Unable to load the "${options.preset}" preset package. Please make sure it's installed.`)); | ||
return cb(new Error(`Unable to load the "${options.preset}" preset package. Please make sure it's installed.`)) | ||
} | ||
@@ -38,8 +38,8 @@ } | ||
const whatBump = options.whatBump || | ||
((config.recommendedBumpOpts && config.recommendedBumpOpts.whatBump) ? | ||
config.recommendedBumpOpts.whatBump : | ||
noop); | ||
((config.recommendedBumpOpts && config.recommendedBumpOpts.whatBump) | ||
? config.recommendedBumpOpts.whatBump | ||
: noop) | ||
if (typeof whatBump !== `function`) { | ||
throw Error(`whatBump must be a function`); | ||
throw Error(`whatBump must be a function`) | ||
} | ||
@@ -52,12 +52,12 @@ | ||
const parserOpts = Object.assign({}, | ||
config.recommendedBumpOpts && config.recommendedBumpOpts.parserOpts ? | ||
config.recommendedBumpOpts.parserOpts : | ||
config.parserOpts, | ||
parserOptsArgument); | ||
config.recommendedBumpOpts && config.recommendedBumpOpts.parserOpts | ||
? config.recommendedBumpOpts.parserOpts | ||
: config.parserOpts, | ||
parserOptsArgument) | ||
const warn = typeof parserOpts.warn === `function` ? parserOpts.warn : noop; | ||
const warn = typeof parserOpts.warn === `function` ? parserOpts.warn : noop | ||
gitSemverTags((err, tags) => { | ||
if (err) { | ||
return cb(err); | ||
return cb(err) | ||
} | ||
@@ -70,20 +70,20 @@ | ||
}) | ||
.pipe(conventionalCommitsParser(parserOpts)) | ||
.pipe(concat(data => { | ||
const commits = options.ignoreReverted ? conventionalCommitsFilter(data) : data; | ||
.pipe(conventionalCommitsParser(parserOpts)) | ||
.pipe(concat(data => { | ||
const commits = options.ignoreReverted ? conventionalCommitsFilter(data) : data | ||
if (!commits || !commits.length) { | ||
warn(`No commits since last release`); | ||
} | ||
if (!commits || !commits.length) { | ||
warn(`No commits since last release`) | ||
} | ||
let result = whatBump(commits); | ||
let result = whatBump(commits) | ||
if (result && result.level != null) { | ||
result.releaseType = VERSIONS[result.level]; | ||
} else if (result == null) { | ||
result = {}; | ||
} | ||
if (result && result.level != null) { | ||
result.releaseType = VERSIONS[result.level] | ||
} else if (result == null) { | ||
result = {} | ||
} | ||
cb(null, result); | ||
})); | ||
cb(null, result) | ||
})) | ||
}, | ||
@@ -94,6 +94,6 @@ { | ||
tagPrefix: options.tagPrefix | ||
}); | ||
}).catch(err => cb(err)); | ||
}) | ||
}).catch(err => cb(err)) | ||
} | ||
function noop() {} | ||
function noop () {} |
{ | ||
"name": "conventional-recommended-bump", | ||
"version": "2.0.6", | ||
"version": "2.0.7", | ||
"description": "Get a recommended version bump based on conventional commits", | ||
@@ -32,7 +32,7 @@ "bugs": { | ||
"concat-stream": "^1.6.0", | ||
"conventional-changelog-preset-loader": "^1.1.6", | ||
"conventional-commits-filter": "^1.1.5", | ||
"conventional-commits-parser": "^2.1.5", | ||
"git-raw-commits": "^1.3.4", | ||
"git-semver-tags": "^1.3.4", | ||
"conventional-changelog-preset-loader": "^1.1.7", | ||
"conventional-commits-filter": "^1.1.6", | ||
"conventional-commits-parser": "^2.1.6", | ||
"git-raw-commits": "^1.3.5", | ||
"git-semver-tags": "^1.3.5", | ||
"meow": "^4.0.0", | ||
@@ -48,3 +48,3 @@ "q": "^1.5.1" | ||
"scripts": { | ||
"lint": "jshint *.js --exclude node_modules && jscs *.js", | ||
"lint": "eslint --fix .", | ||
"test": "npm run-script lint && mocha --timeout 30000 *.spec.js", | ||
@@ -51,0 +51,0 @@ "test-windows": "mocha --timeout 30000 preset-resolver.spec.js" |
@@ -1,7 +0,7 @@ | ||
'use strict'; | ||
'use strict' | ||
const Q = require(`q`); | ||
const Q = require(`q`) | ||
module.exports = presetPackage => (typeof presetPackage === `function` || typeof presetPackage === `object`) ? | ||
(typeof presetPackage === `function` ? Q.nfcall(presetPackage) : new Q(presetPackage)) : | ||
Promise.reject(new Error(`preset package must be a promise, funciton, or object`)); | ||
module.exports = presetPackage => (typeof presetPackage === `function` || typeof presetPackage === `object`) | ||
? (typeof presetPackage === `function` ? Q.nfcall(presetPackage) : new Q(presetPackage)) | ||
: Promise.reject(new Error(`preset package must be a promise, funciton, or object`)) |
19374