Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: cli application accept path option #279

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
9 changes: 9 additions & 0 deletions command.js
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
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
Expand Up @@ -24,7 +24,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 @@ -125,15 +125,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
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