forked from conventional-changelog/commitlint
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
31 lines (29 loc) · 782 Bytes
/
index.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
const {Workspaces} = require('@nrwl/tao/src/shared/workspace');
module.exports = {
utils: {getProjects},
rules: {
'scope-enum': (ctx) =>
getProjects(ctx).then((packages) => [2, 'always', packages]),
},
};
function getProjects(context) {
return Promise.resolve()
.then(() => {
const ctx = context || {};
const cwd = ctx.cwd || process.cwd();
const ws = new Workspaces(cwd);
const workspace = ws.readWorkspaceConfiguration();
return Object.entries(workspace.projects || {}).map(
([name, project]) => ({
name,
...project,
})
);
})
.then((projects) => {
return projects
.filter((project) => project.targets)
.map((project) => project.name)
.map((name) => (name.charAt(0) === '@' ? name.split('/')[1] : name));
});
}