Skip to content

Commit

Permalink
cleanup(core): do not use workspaceRoot when resolving local files
Browse files Browse the repository at this point in the history
  • Loading branch information
vsavkin committed May 23, 2022
1 parent 66b759d commit e541a8a
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 15 deletions.
6 changes: 2 additions & 4 deletions packages/nx/bin/run-executor.ts
Original file line number Diff line number Diff line change
@@ -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(
Expand All @@ -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,
Expand Down
6 changes: 1 addition & 5 deletions packages/nx/src/tasks-runner/cache.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
2 changes: 1 addition & 1 deletion packages/nx/src/tasks-runner/forked-process-task-runner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<ChildProcess>();

Expand Down
7 changes: 2 additions & 5 deletions packages/nx/src/tasks-runner/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit e541a8a

Please sign in to comment.