forked from Tencent/tdesign-vue-next
-
Notifications
You must be signed in to change notification settings - Fork 0
/
commitlint.config.js
32 lines (29 loc) · 885 Bytes
/
commitlint.config.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
const fs = require('fs');
const path = require('path');
const { execSync } = require('child_process');
const packages = fs
.readdirSync(path.resolve(__dirname, 'src'), { withFileTypes: true })
.filter((dirent) => dirent.isDirectory())
.map((dirent) => dirent.name);
// precomputed scope
const scopeComplete = execSync('git status --porcelain || true')
.toString()
.trim()
.split('\n')
.find((r) => r.indexOf('M ') !== -1)
?.replace(/(\/)/g, '%%')
?.match(/src%%((\w|-)*)/)?.[1];
/** @type {import('cz-git').UserConfig} */
module.exports = {
extends: ['@commitlint/config-conventional'],
prompt: {
scopes: [...packages],
customScopesAlign: !scopeComplete ? 'top-bottom' : 'bottom',
scopeOverrides: {
test: ['unit', 'e2e'],
},
defaultScope: scopeComplete,
allowEmptyIssuePrefixs: false,
allowCustomIssuePrefixs: false,
},
};