Skip to content

Commit

Permalink
fix(workspace): topoligically sort projects for affected:build --all
Browse files Browse the repository at this point in the history
Closes #1302

Aligns behaviour of `affected --base=[SHA] --head=[SHA]` and `affected --all`
  • Loading branch information
dherges authored and vsavkin committed May 2, 2019
1 parent 0afcbb3 commit 85351a3
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
4 changes: 2 additions & 2 deletions packages/workspace/src/command-line/affected.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import {
getAllLibNames,
getProjectNames,
parseFiles,
getAllProjectNamesWithTarget,
getAllProjectsWithTarget,
getAffectedProjectsWithTarget,
readAngularJson
} from './shared';
Expand Down Expand Up @@ -123,7 +123,7 @@ function getProjects(
all: boolean
) {
const projects = all
? getAllProjectNamesWithTarget(target)
? getAllProjectsWithTarget(target)
: getAffectedProjectsWithTarget(target)(parseFiles(parsedArgs).files);

return projects
Expand Down
10 changes: 10 additions & 0 deletions packages/workspace/src/command-line/shared.ts
Original file line number Diff line number Diff line change
Expand Up @@ -349,6 +349,16 @@ export function getAllProjectNamesWithTarget(target: string) {
return getProjectNames(p => p.architect[target]);
}

export function getAllProjectsWithTarget(target: string) {
const angularJson = readAngularJson();
const nxJson = readNxJson();
const projects = getProjectNodes(angularJson, nxJson);
const dependencies = readDependencies(nxJson.npmScope, projects);
const sortedProjects = topologicallySortProjects(projects, dependencies);

return sortedProjects.filter(p => p.architect[target]).map(p => p.name);
}

export function getProjectNames(
predicate?: (projectNode: ProjectNode) => boolean
): string[] {
Expand Down

0 comments on commit 85351a3

Please sign in to comment.