diff --git a/packages/nx/bin/run-executor.ts b/packages/nx/bin/run-executor.ts index 6eaf0732e1..f971079a3e 100644 --- a/packages/nx/bin/run-executor.ts +++ b/packages/nx/bin/run-executor.ts @@ -1,4 +1,5 @@ import { appendFileSync, openSync, writeFileSync } from 'fs'; +import { run } from '../src/command-line/run'; if (process.env.NX_TERMINAL_OUTPUT_PATH) { setUpOutputWatching( @@ -17,10 +18,7 @@ function requireCli() { process.env.NX_CLI_SET = 'true'; try { const args = JSON.parse(process.argv[2]); - const e = require(require.resolve('nx/src/command-line/run.js', { - paths: [process.env.NX_WORKSPACE_ROOT], - })); - e.run( + run( process.cwd(), process.env.NX_WORKSPACE_ROOT, args.targetDescription, diff --git a/packages/nx/src/tasks-runner/cache.ts b/packages/nx/src/tasks-runner/cache.ts index 7f6ff00f4e..8c89b3d975 100644 --- a/packages/nx/src/tasks-runner/cache.ts +++ b/packages/nx/src/tasks-runner/cache.ts @@ -42,11 +42,7 @@ export class Cache { */ const shouldSpawnProcess = Math.floor(Math.random() * 50) === 1; if (shouldSpawnProcess) { - const scriptPath = require.resolve( - 'nx/src/tasks-runner/remove-old-cache-records.js', - { paths: [this.root] } - ); - + const scriptPath = require.resolve('./remove-old-cache-records.js'); try { const p = spawn('node', [scriptPath, `"${this.cachePath}"`], { stdio: 'ignore', diff --git a/packages/nx/src/tasks-runner/forked-process-task-runner.ts b/packages/nx/src/tasks-runner/forked-process-task-runner.ts index c85ad49f29..5897c27fa9 100644 --- a/packages/nx/src/tasks-runner/forked-process-task-runner.ts +++ b/packages/nx/src/tasks-runner/forked-process-task-runner.ts @@ -23,7 +23,7 @@ const workerPath = join(__dirname, './batch/run-batch.js'); export class ForkedProcessTaskRunner { workspaceRoot = workspaceRoot; - cliPath = getCliPath(this.workspaceRoot); + cliPath = getCliPath(); private processes = new Set(); diff --git a/packages/nx/src/tasks-runner/utils.ts b/packages/nx/src/tasks-runner/utils.ts index 061482ec61..bb9125e929 100644 --- a/packages/nx/src/tasks-runner/utils.ts +++ b/packages/nx/src/tasks-runner/utils.ts @@ -246,11 +246,8 @@ export function calculateReverseDeps( return reverseTaskDeps; } -export function getCliPath(workspaceRoot: string) { - const cli = require.resolve(`nx/bin/run-executor.js`, { - paths: [workspaceRoot], - }); - return `${cli}`; +export function getCliPath() { + return require.resolve(`../../bin/run-executor.js`); } export function getPrintableCommandArgsForTask(task: Task) {