Skip to content
This repository has been archived by the owner on Jul 9, 2024. It is now read-only.

Commit

Permalink
fix(nx-affected-matrix): matrix output missing distribution
Browse files Browse the repository at this point in the history
  • Loading branch information
Ron Netzer committed Jul 29, 2021
1 parent 04eb5ae commit 00380e7
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions packages/nx-affected-matrix/src/lib/nx-affected-matrix.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,14 @@ import {
getMaxDistribution,
} from '../../../utils/src';

interface NxAffectedTarget {
target: string;
distribution: number;
projects: string;
}

interface NxAffectedMatrix {
include: { target: string; distribution: number; projects: string }[];
include: NxAffectedTarget[];
}

export function chunkify<T>(arr: T[], numberOfChunks: number): T[][] {
Expand Down Expand Up @@ -41,7 +47,7 @@ export async function generateAffectedMatrix(
exec: Exec
): Promise<NxAffectedMatrix> {
startGroup(`⚙️ Generating affected matrix for ${targets}`);
const matrix = {
const matrix: NxAffectedMatrix = {
include: [],
};

Expand All @@ -51,10 +57,10 @@ export async function generateAffectedMatrix(
exec.withArgs(`--base=${base}`, `--head=${head}`, ...args);
debug(`🐞 Calculating affected for "${target}" target`);
const projects = await nxPrintAffected(target, exec);
const affectedTargets = chunkify(projects, maxDistribution[target])
const affectedTargets: NxAffectedTarget[] = chunkify(projects, maxDistribution[target])
.map((projects, idx) => ({
target,
bucket: idx + 1,
distribution: idx + 1,
projects: projects.join(','),
}))
.filter((target) => target.projects !== '');
Expand Down

0 comments on commit 00380e7

Please sign in to comment.