Skip to content

Commit

Permalink
feat: commit check can read from a custom file
Browse files Browse the repository at this point in the history
  • Loading branch information
varl committed Dec 18, 2020
1 parent 2c8688d commit 366be0c
Show file tree
Hide file tree
Showing 3 changed files with 919 additions and 1,015 deletions.
17 changes: 12 additions & 5 deletions src/commands/commit.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,23 @@
const log = require('@dhis2/cli-helpers-engine').reporter
const { namespace } = require('@dhis2/cli-helpers-engine')
const { commitlint } = require('../tools/commitlint.js')
const { CONSUMING_ROOT } = require('../utils/paths.js')

const commitCmd = yargs => {
return yargs.command(
'check [file]',
'Checks commit messages according to standards.',
'Checks commit messages according to standard.',
function builder(yargs) {
return yargs.option('commitlintConfig', {
describe: 'Commitlint config file to use',
type: 'string',
})
return yargs
.positional('file', {
describe: 'File that contains the commit message',
type: 'string',
default: `${CONSUMING_ROOT}/.git/COMMIT_EDITMSG`,
})
.option('commitlintConfig', {
describe: 'Commitlint config file to use',
type: 'string',
})
},
function handler(argv) {
log.info('d2-style > commit')
Expand Down
4 changes: 2 additions & 2 deletions src/tools/commitlint.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
const { COMMITLINT_CONFIG } = require('../utils/paths.js')
const { bin } = require('../utils/run.js')

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

Expand Down
Loading

0 comments on commit 366be0c

Please sign in to comment.