Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(misc): improve print-affected perf #12822

Merged
merged 1 commit into from Oct 25, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 3 additions & 1 deletion packages/nx/src/command-line/print-affected.ts
Expand Up @@ -9,6 +9,7 @@ import { Workspaces } from '../config/workspaces';
import { Hasher } from '../hasher/hasher';
import { hashTask } from '../hasher/hash-task';
import { workspaceRoot } from '../utils/workspace-root';
import { getPackageManagerCommand } from 'nx/src/utils/package-manager';

export async function printAffected(
affectedProjectsWithTargetAndConfig: ProjectGraphProjectNode[],
Expand Down Expand Up @@ -51,6 +52,7 @@ async function createTasks(
) {
const workspaces = new Workspaces(workspaceRoot);
const hasher = new Hasher(projectGraph, nxJson, {});
const execCommand = getPackageManagerCommand().exec;

const tasks: Task[] = affectedProjectsWithTargetAndConfig.map(
(affectedProject) => {
Expand Down Expand Up @@ -79,7 +81,7 @@ async function createTasks(
overrides,
target: task.target,
hash: task.hash,
command: getCommandAsString(task),
command: getCommandAsString(execCommand, task),
outputs: getOutputs(projectGraph.nodes, task),
}));
}
Expand Down
5 changes: 1 addition & 4 deletions packages/nx/src/tasks-runner/utils.ts
Expand Up @@ -9,17 +9,14 @@ import {
mergePluginTargetsWithNxTargets,
} from '../utils/nx-plugin';
import { Task, TaskGraph } from '../config/task-graph';
import { getPackageManagerCommand } from '../utils/package-manager';
import { ProjectGraph, ProjectGraphProjectNode } from '../config/project-graph';
import { TargetDependencyConfig } from '../config/workspace-json-project-json';
import { workspaceRoot } from '../utils/workspace-root';
import { NxJsonConfiguration } from '../config/nx-json';
import { joinPathFragments } from '../utils/path';
import { logger } from '../utils/logger';
import { isRelativePath } from 'nx/src/utils/fileutils';

export function getCommandAsString(task: Task) {
const execCommand = getPackageManagerCommand().exec;
export function getCommandAsString(execCommand: string, task: Task) {
const args = getPrintableCommandArgsForTask(task);
return [execCommand, 'nx', ...args].join(' ').trim();
}
Expand Down