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
24 lines (20 loc) · 690 Bytes
/
index.js
File metadata and controls
24 lines (20 loc) · 690 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
import path from "node:path";
import configAngular from "@commitlint/config-angular";
import { glob } from "glob";
import merge from "lodash.merge";
function pathToId(root, filePath) {
const relativePath = path.relative(root, filePath);
return path.dirname(relativePath).split(path.sep).join("/");
}
async function getPatternIDs() {
const root = path.resolve(process.cwd(), "./patterns");
const pattern = path.resolve(root, "**/pattern.json");
const files = glob(pattern);
return files.map((result) => pathToId(root, result));
}
export default merge(configAngular, {
rules: {
"scope-enum": () =>
getPatternIDs().then((ids) => [2, "always", ids.concat(["system"])]),
},
});