diff --git a/packages/nx/src/executors/run-script/run-script.impl.ts b/packages/nx/src/executors/run-script/run-script.impl.ts index ab685b33b448c..089ecbb5147f0 100644 --- a/packages/nx/src/executors/run-script/run-script.impl.ts +++ b/packages/nx/src/executors/run-script/run-script.impl.ts @@ -1,8 +1,8 @@ -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'; +import { runCommand } from '../../native'; export interface RunScriptOptions { script: string; @@ -15,16 +15,25 @@ export default async function ( ) { const pm = getPackageManagerCommand(); try { - execSync(pm.run(options.script, options.__unparsed__.join(' ')), { - stdio: ['inherit', 'inherit', 'inherit'], - cwd: path.join( - context.root, - context.projectsConfigurations.projects[context.projectName].root - ), - env: { - ...process.env, - ...appendLocalEnv(), - }, + await new Promise((res, rej) => { + const cp = runCommand( + pm.run(options.script, options.__unparsed__.join(' ')), + path.join( + context.root, + context.projectsConfigurations.projects[context.projectName].root + ), + { + ...process.env, + ...appendLocalEnv(), + } + ); + cp.onExit((code) => { + if (code === 0) { + res(); + } else { + rej(); + } + }); }); return { success: true }; } catch (e) { diff --git a/packages/nx/src/tasks-runner/run-command.ts b/packages/nx/src/tasks-runner/run-command.ts index 8dc50bd64d8ef..a2c2205a64457 100644 --- a/packages/nx/src/tasks-runner/run-command.ts +++ b/packages/nx/src/tasks-runner/run-command.ts @@ -24,16 +24,9 @@ import { createTaskGraph } from './create-task-graph'; import { findCycle, makeAcyclic } from './task-graph-utils'; import { TargetDependencyConfig } from '../config/workspace-json-project-json'; import { handleErrors } from '../utils/params'; -import { - DaemonBasedTaskHasher, - InProcessTaskHasher, - TaskHasher, -} from '../hasher/task-hasher'; import { hashTasksThatDoNotDependOnOutputsOfOtherTasks } from '../hasher/hash-task'; import { daemonClient } from '../daemon/client/client'; import { StoreRunInformationLifeCycle } from './life-cycles/store-run-information-life-cycle'; -import { getFileMap } from '../project-graph/build-project-graph'; -import { performance } from 'perf_hooks'; import { createTaskHasher } from '../hasher/create-task-hasher'; async function getTerminalOutputLifeCycle(