forked from conventional-changelog/commitlint
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
26 lines (23 loc) · 669 Bytes
/
Copy pathindex.js
File metadata and controls
26 lines (23 loc) · 669 Bytes
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
const path = require('path');
const globby = require('globby');
const merge = require('lodash/merge');
function pathToId(root, filePath) {
const relativePath = path.relative(root, filePath);
return path
.dirname(relativePath)
.split(path.sep)
.join('/');
}
function getPatternIDs() {
const root = path.resolve(process.cwd(), './patterns');
const glob = path.resolve(root, '**/pattern.json');
return globby(glob).then(results =>
results.map(result => pathToId(root, result))
);
}
module.exports = merge(require('@commitlint/config-angular'), {
rules: {
'scope-enum': () =>
getPatternIDs().then(ids => [2, 'always', ids.concat(['system'])])
}
});