Skip to content

Commit

Permalink
fix: allow optional commit-msg file to lint
Browse files Browse the repository at this point in the history
  • Loading branch information
varl committed Dec 16, 2020
1 parent df1827b commit 83b06db
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
7 changes: 5 additions & 2 deletions src/commands/commit.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ const { commitlint } = require('../tools/commitlint.js')

const commitCmd = yargs => {
return yargs.command(
'check',
'check [file]',
'Checks commit messages according to standards.',
function builder(yargs) {
return yargs.option('commitlintConfig', {
Expand All @@ -15,7 +15,10 @@ const commitCmd = yargs => {
},
function handler(argv) {
log.info('d2-style > commit')
commitlint(argv.commitlintConfig)
commitlint({
config: argv.commitlintConfig,
file: argv.file,
})
}
)
}
Expand Down
9 changes: 7 additions & 2 deletions src/tools/commitlint.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,14 @@
const { bin } = require('../utils/run.js')
const { COMMITLINT_CONFIG } = require('../utils/paths.js')

exports.commitlint = (config = COMMITLINT_CONFIG) => {
exports.commitlint = ({ config = COMMITLINT_CONFIG, file }) => {
const cmd = 'commitlint'
const args = ['commitlint', `--config=${config}`, '--edit']
const args = [
'commitlint',
`--config=${config}`,
'--edit',
...(file ? [file] : []),
]

bin(cmd, { args })
}

0 comments on commit 83b06db

Please sign in to comment.