Skip to content

Commit

Permalink
feat: cli application accept path/preset option (#279)
Browse files Browse the repository at this point in the history
  • Loading branch information
aldoreno authored and bcoe committed Feb 14, 2019
1 parent 96216da commit 69c62cf
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 6 deletions.
9 changes: 9 additions & 0 deletions command.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,15 @@ module.exports = require('yargs')
default: defaults.gitTagFallback,
describe: `fallback to git tags for version, if no meta-information file is found (e.g., package.json)`
})
.option('path', {
type: 'string',
describe: 'Only populate commits made under this path'
})
.option('preset', {
type: 'string',
default: defaults.preset,
describe: 'Commit message guideline preset (default: angular)'
})
.check((argv) => {
if (typeof argv.scripts !== 'object' || Array.isArray(argv.scripts)) {
throw Error('scripts must be an object')
Expand Down
3 changes: 2 additions & 1 deletion defaults.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,6 @@
"scripts": {},
"skip": {},
"dryRun": false,
"gitTagFallback": true
"gitTagFallback": true,
"preset": "angular"
}
8 changes: 5 additions & 3 deletions lib/lifecycles/bump.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ function Bump (args, version) {
.then(runLifecycleScript.bind(this, args, 'prebump'))
.then((stdout) => {
if (stdout && stdout.trim().length) args.releaseAs = stdout.trim()
return bumpVersion(args.releaseAs)
return bumpVersion(args.releaseAs, args)
})
.then((release) => {
if (!args.firstRelease) {
Expand Down Expand Up @@ -128,15 +128,17 @@ function getTypePriority (type) {
return TypeList.indexOf(type)
}

function bumpVersion (releaseAs, callback) {
function bumpVersion (releaseAs, args) {
return new Promise((resolve, reject) => {
if (releaseAs) {
return resolve({
releaseType: releaseAs
})
} else {
conventionalRecommendedBump({
preset: 'angular'
debug: args.verbose && console.info.bind(console, 'conventional-recommended-bump'),
preset: args.preset || 'angular',
path: args.path
}, function (err, release) {
if (err) return reject(err)
else return resolve(release)
Expand Down
5 changes: 3 additions & 2 deletions lib/lifecycles/changelog.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,10 @@ function outputChangelog (args, newVersion) {
var context
if (args.dryRun) context = { version: newVersion }
var changelogStream = conventionalChangelog({
preset: 'angular',
debug: args.verbose && console.info.bind(console, 'conventional-changelog'),
preset: args.preset || 'angular',
tagPrefix: args.tagPrefix
}, context, { merges: null })
}, context, { merges: null, path: args.path })
.on('error', function (err) {
return reject(err)
})
Expand Down

0 comments on commit 69c62cf

Please sign in to comment.