-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore(misc): address review feedback
- Loading branch information
1 parent
84650b3
commit 8ec97e3
Showing
7 changed files
with
110 additions
and
73 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
76 changes: 26 additions & 50 deletions
76
packages/nx/src/project-graph/build-nodes/workspace-projects.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,70 +1,46 @@ | ||
import { ProjectConfiguration } from 'nx/src/config/workspace-json-project-json'; | ||
import { normalizeImplicitDependencies } from './workspace-projects'; | ||
|
||
describe('workspace-projects', () => { | ||
let projectsSet: Set<string>; | ||
|
||
beforeEach(() => { | ||
projectsSet = new Set(['test-project', 'a', 'b', 'c']); | ||
}); | ||
|
||
describe('normalizeImplicitDependencies', () => { | ||
it('should expand "*" implicit dependencies', () => { | ||
expect( | ||
normalizeImplicitDependencies('test-project', ['*'], { | ||
fileMap: {}, | ||
filesToProcess: {}, | ||
workspace: { | ||
version: 2, | ||
projects: { | ||
...makeProject('test-project'), | ||
...makeProject('a'), | ||
...makeProject('b'), | ||
...makeProject('c'), | ||
}, | ||
}, | ||
}) | ||
normalizeImplicitDependencies( | ||
'test-project', | ||
['*'], | ||
Array.from(projectsSet), | ||
projectsSet | ||
) | ||
).toEqual(['a', 'b', 'c']); | ||
}); | ||
|
||
it('should return [] for null implicit dependencies', () => { | ||
expect( | ||
normalizeImplicitDependencies('test-project', null, { | ||
fileMap: {}, | ||
filesToProcess: {}, | ||
workspace: { | ||
version: 2, | ||
projects: { | ||
...makeProject('test-project'), | ||
...makeProject('a'), | ||
...makeProject('b'), | ||
...makeProject('c'), | ||
}, | ||
}, | ||
}) | ||
normalizeImplicitDependencies( | ||
'test-project', | ||
null, | ||
Array.from(projectsSet), | ||
projectsSet | ||
) | ||
).toEqual([]); | ||
}); | ||
|
||
it('should expand glob based implicit dependencies', () => { | ||
projectsSet.add('b-1'); | ||
projectsSet.add('b-2'); | ||
expect( | ||
normalizeImplicitDependencies('test-project', ['b*'], { | ||
fileMap: {}, | ||
filesToProcess: {}, | ||
workspace: { | ||
version: 2, | ||
projects: { | ||
...makeProject('test-project'), | ||
...makeProject('a'), | ||
...makeProject('b'), | ||
...makeProject('b-1'), | ||
...makeProject('b-2'), | ||
...makeProject('c'), | ||
}, | ||
}, | ||
}) | ||
normalizeImplicitDependencies( | ||
'test-project', | ||
['b*'], | ||
Array.from(projectsSet), | ||
projectsSet | ||
) | ||
).toEqual(['b', 'b-1', 'b-2']); | ||
}); | ||
}); | ||
}); | ||
|
||
function makeProject(name: string): Record<string, ProjectConfiguration> { | ||
return { | ||
[name]: { | ||
root: `packages/${name}`, | ||
}, | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import { findMatchingProjects } from './find-matching-projects'; | ||
|
||
describe('findMatchingProjects', () => { | ||
let projectsSet: Set<string>; | ||
|
||
beforeEach(() => { | ||
projectsSet = new Set(['test-project', 'a', 'b', 'c']); | ||
}); | ||
|
||
it('should expand "*"', () => { | ||
expect( | ||
findMatchingProjects(['*'], Array.from(projectsSet), projectsSet) | ||
).toEqual(['test-project', 'a', 'b', 'c']); | ||
}); | ||
|
||
it('should expand generic glob patterns', () => { | ||
projectsSet.add('b-1'); | ||
projectsSet.add('b-2'); | ||
|
||
expect( | ||
findMatchingProjects(['b*'], Array.from(projectsSet), projectsSet) | ||
).toEqual(['b', 'b-1', 'b-2']); | ||
}); | ||
|
||
it('should support projectNames', () => { | ||
expect( | ||
findMatchingProjects(['a', 'b'], Array.from(projectsSet), projectsSet) | ||
).toEqual(['a', 'b']); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters