Skip to content

Commit

Permalink
refactor: adjust config-nx-scopes filtering implementation
Browse files Browse the repository at this point in the history
  • Loading branch information
jaytavares committed May 11, 2022
1 parent c49195f commit cb57453
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions @commitlint/config-nx-scopes/index.js
Expand Up @@ -8,7 +8,10 @@ module.exports = {
},
};

function getProjects(context, filterFunc) {
/**
* @param {(params: Pick<Nx.ProjectConfiguration, 'name' | 'projectType' | 'tags'>) => boolean} selector
*/
function getProjects(context, selector = () => true) {
return Promise.resolve()
.then(() => {
const ctx = context || {};
Expand All @@ -25,13 +28,11 @@ function getProjects(context, filterFunc) {
.then((projects) => {
return projects
.filter((project) =>
filterFunc
? filterFunc({
name: project.name,
type: project.projectType,
tags: project.tags,
})
: true
selector({
name: project.name,
projectType: project.projectType,
tags: project.tags,
})
)
.filter((project) => project.targets)
.map((project) => project.name)
Expand Down

0 comments on commit cb57453

Please sign in to comment.