Skip to content

Commit 2626edf

Browse files
committed
fix(nx-plugin): print stdout for CLI command
1 parent 4367e53 commit 2626edf

File tree

1 file changed

+20
-5
lines changed

1 file changed

+20
-5
lines changed

packages/nx-plugin/src/executors/cli/executor.ts

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,19 @@ import { execSync } from 'node:child_process';
33
import { createCliCommand } from '../internal/cli.js';
44
import { normalizeContext } from '../internal/context.js';
55
import type { AutorunCommandExecutorOptions } from './schema.js';
6-
import { mergeExecutorOptions, parseAutorunExecutorOptions } from './utils.js';
6+
import {
7+
mergeExecutorOptions,
8+
objectToCliArgs,
9+
parseAutorunExecutorOptions,
10+
} from './utils.js';
711

812
export type ExecutorOutput = {
913
success: boolean;
1014
command?: string;
1115
error?: Error;
1216
};
1317

14-
export default function runAutorunExecutor(
18+
export default async function runAutorunExecutor(
1519
terminalAndExecutorOptions: AutorunCommandExecutorOptions,
1620
context: ExecutorContext,
1721
): Promise<ExecutorOutput> {
@@ -36,9 +40,20 @@ export default function runAutorunExecutor(
3640
logger.warn(`DryRun execution of: ${commandString}`);
3741
} else {
3842
try {
39-
// @TODO use executeProcess instead of execSync -> non blocking, logs #761
40-
// eslint-disable-next-line n/no-sync
41-
execSync(commandString, commandStringOptions);
43+
const { executeProcess }: typeof import('@code-pushup/utils') =
44+
await import('@code-pushup/utils');
45+
await executeProcess({
46+
command: command,
47+
args: objectToCliArgs(cliArgumentObject),
48+
observer: {
49+
error: data => {
50+
process.stderr.write(data);
51+
},
52+
next: data => {
53+
process.stdout.write(data);
54+
},
55+
},
56+
});
4257
} catch (error) {
4358
logger.error(error);
4459
return Promise.resolve({

0 commit comments

Comments
 (0)