Skip to content

Commit

Permalink
fix(misc): improve print-affected perf (#12822)
Browse files Browse the repository at this point in the history
  • Loading branch information
FrozenPandaz committed Oct 25, 2022
1 parent 36faa03 commit 58f96de
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 5 deletions.
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

0 comments on commit 58f96de

Please sign in to comment.