Skip to content

Commit

Permalink
fix(core): workspaceRoot/node_modules/.bin should be in path during `…
Browse files Browse the repository at this point in the history
…nx exec`
  • Loading branch information
AgentEnder committed Feb 22, 2023
1 parent f8d4995 commit 3743a1d
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
6 changes: 4 additions & 2 deletions packages/nx/src/command-line/exec.ts
Expand Up @@ -5,7 +5,6 @@ import * as yargs from 'yargs-parser';

import { readNxJson } from '../config/configuration';
import { ProjectGraph, ProjectGraphProjectNode } from '../config/project-graph';
import { ProjectConfiguration } from '../config/workspace-json-project-json';
import {
createProjectGraphAsync,
readProjectsConfigurationFromProjectGraph,
Expand All @@ -28,7 +27,10 @@ export async function nxExecCommand(
const command = scriptArgV
.reduce((cmd, arg) => cmd + `"${arg}" `, '')
.trim();
execSync(command, { stdio: 'inherit' });
execSync(command, {
stdio: 'inherit',
env: process.env,
});
} else {
// nx exec is being ran inside of Nx's context
return runScriptAsNxTarget(scriptArgV);
Expand Down
5 changes: 5 additions & 0 deletions packages/nx/src/executors/run-script/run-script.impl.ts
Expand Up @@ -2,6 +2,7 @@ import { execSync } from 'child_process';
import { getPackageManagerCommand } from '../../utils/package-manager';
import type { ExecutorContext } from '../../config/misc-interfaces';
import * as path from 'path';
import { env as appendLocalEnv } from 'npm-run-path';

export interface RunScriptOptions {
script: string;
Expand All @@ -20,6 +21,10 @@ export default async function (
context.root,
context.projectsConfigurations.projects[context.projectName].root
),
env: {
...process.env,
...appendLocalEnv(),
},
});
return { success: true };
} catch (e) {
Expand Down

0 comments on commit 3743a1d

Please sign in to comment.