cleanup(core): do not use workspaceRoot when resolving local files

This commit is contained in:
Victor Savkin 2022-05-23 18:17:36 -04:00
parent 66b759ddc7
commit e541a8adbe
4 changed files with 6 additions and 15 deletions

View File

@ -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,

View File

@ -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',

View File

@ -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>();

View File

@ -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) {