Skip to content

Commit 69c62cf

Browse files
aldorenobcoe
authored andcommittedFeb 14, 2019
feat: cli application accept path/preset option (#279)
1 parent 96216da commit 69c62cf

File tree

4 files changed

+19
-6
lines changed

4 files changed

+19
-6
lines changed
 

‎command.js

+9
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,15 @@ module.exports = require('yargs')
7777
default: defaults.gitTagFallback,
7878
describe: `fallback to git tags for version, if no meta-information file is found (e.g., package.json)`
7979
})
80+
.option('path', {
81+
type: 'string',
82+
describe: 'Only populate commits made under this path'
83+
})
84+
.option('preset', {
85+
type: 'string',
86+
default: defaults.preset,
87+
describe: 'Commit message guideline preset (default: angular)'
88+
})
8089
.check((argv) => {
8190
if (typeof argv.scripts !== 'object' || Array.isArray(argv.scripts)) {
8291
throw Error('scripts must be an object')

‎defaults.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,6 @@
1010
"scripts": {},
1111
"skip": {},
1212
"dryRun": false,
13-
"gitTagFallback": true
13+
"gitTagFallback": true,
14+
"preset": "angular"
1415
}

‎lib/lifecycles/bump.js

+5-3
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ function Bump (args, version) {
2727
.then(runLifecycleScript.bind(this, args, 'prebump'))
2828
.then((stdout) => {
2929
if (stdout && stdout.trim().length) args.releaseAs = stdout.trim()
30-
return bumpVersion(args.releaseAs)
30+
return bumpVersion(args.releaseAs, args)
3131
})
3232
.then((release) => {
3333
if (!args.firstRelease) {
@@ -128,15 +128,17 @@ function getTypePriority (type) {
128128
return TypeList.indexOf(type)
129129
}
130130

131-
function bumpVersion (releaseAs, callback) {
131+
function bumpVersion (releaseAs, args) {
132132
return new Promise((resolve, reject) => {
133133
if (releaseAs) {
134134
return resolve({
135135
releaseType: releaseAs
136136
})
137137
} else {
138138
conventionalRecommendedBump({
139-
preset: 'angular'
139+
debug: args.verbose && console.info.bind(console, 'conventional-recommended-bump'),
140+
preset: args.preset || 'angular',
141+
path: args.path
140142
}, function (err, release) {
141143
if (err) return reject(err)
142144
else return resolve(release)

‎lib/lifecycles/changelog.js

+3-2
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,10 @@ function outputChangelog (args, newVersion) {
3030
var context
3131
if (args.dryRun) context = { version: newVersion }
3232
var changelogStream = conventionalChangelog({
33-
preset: 'angular',
33+
debug: args.verbose && console.info.bind(console, 'conventional-changelog'),
34+
preset: args.preset || 'angular',
3435
tagPrefix: args.tagPrefix
35-
}, context, { merges: null })
36+
}, context, { merges: null, path: args.path })
3637
.on('error', function (err) {
3738
return reject(err)
3839
})

0 commit comments

Comments
 (0)
Please sign in to comment.