1 | 'use strict'
|
2 | const path = require('path')
|
3 | const execa = require('execa')
|
4 | const commitlintTravis = require('../src/checks/commitlint-travis')
|
5 |
|
6 | const EPILOG = `
|
7 | Supports options forwarding with '--' for more info check https://conventional-changelog.github.io/commitlint/#/reference-cli
|
8 | `
|
9 |
|
10 | module.exports = {
|
11 | command: 'commitlint',
|
12 | aliases: ['cl', 'commit'],
|
13 | desc: 'Run `commitlint` cli with aegir defaults.',
|
14 | builder: (yargs) => {
|
15 | yargs
|
16 | .epilog(EPILOG)
|
17 | .example('npx aegir commitlint -- -E HUSKY_GIT_PARAMS', 'To use inside a package.json as a Husky commit-msg hook.')
|
18 | .options({
|
19 | travis: {
|
20 | describe: 'Run `commitlint` in Travis CI mode.',
|
21 | boolean: true
|
22 | }
|
23 | })
|
24 | },
|
25 | handler (argv) {
|
26 | if (argv.travis) {
|
27 | return commitlintTravis()
|
28 | }
|
29 |
|
30 | const input = argv._.slice(1)
|
31 | const forwardOptions = argv['--'] ? argv['--'] : []
|
32 | return execa('commitlint', [
|
33 | '--extends',
|
34 | '@commitlint/config-conventional',
|
35 | ...input,
|
36 | ...forwardOptions
|
37 | ], {
|
38 | stdio: 'inherit',
|
39 | localDir: path.join(__dirname, '..'),
|
40 | preferLocal: true
|
41 | })
|
42 | }
|
43 | }
|