diff --git a/packages/nx/src/command-line/print-affected.ts b/packages/nx/src/command-line/print-affected.ts index 7c411b50f8019..1743abc29e090 100644 --- a/packages/nx/src/command-line/print-affected.ts +++ b/packages/nx/src/command-line/print-affected.ts @@ -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[], @@ -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) => { @@ -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), })); } diff --git a/packages/nx/src/tasks-runner/utils.ts b/packages/nx/src/tasks-runner/utils.ts index 523eabde9fbe1..4264603629087 100644 --- a/packages/nx/src/tasks-runner/utils.ts +++ b/packages/nx/src/tasks-runner/utils.ts @@ -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(); }