11import type { ExecutorContext } from '@nx/devkit' ;
22import { executeProcess } from '../../internal/execute-process.js' ;
3+ import { normalizeContext } from '../internal/context.js' ;
34import type { AutorunCommandExecutorOptions } from './schema.js' ;
5+ import { mergeExecutorOptions , parseAutorunExecutorOptions } from './utils.js' ;
46
57export type ExecutorOutput = {
68 success : boolean ;
@@ -11,10 +13,19 @@ export type ExecutorOutput = {
1113/* eslint-disable max-lines-per-function */
1214export default async function runAutorunExecutor (
1315 terminalAndExecutorOptions : AutorunCommandExecutorOptions ,
14- { cwd } : ExecutorContext ,
16+ context : ExecutorContext ,
1517) : Promise < ExecutorOutput > {
1618 const { logger, stringifyError, objectToCliArgs, formatCommand } =
1719 await import ( '@code-pushup/utils' ) ;
20+ const normalizedContext = normalizeContext ( context ) ;
21+ const mergedOptions = mergeExecutorOptions (
22+ context . target ?. options ,
23+ terminalAndExecutorOptions ,
24+ ) ;
25+ const cliArgumentObject = parseAutorunExecutorOptions (
26+ mergedOptions ,
27+ normalizedContext ,
28+ ) ;
1829 const {
1930 dryRun,
2031 verbose,
@@ -34,7 +45,7 @@ export default async function runAutorunExecutor(
3445 const binString = `${ command } ${ positionals . join ( ' ' ) } ${ args . join ( ' ' ) } ` ;
3546 const formattedBinString = formatCommand ( binString , {
3647 env : executorEnvVariables ,
37- cwd,
48+ cwd : context . cwd ,
3849 } ) ;
3950
4051 if ( dryRun ) {
@@ -44,7 +55,7 @@ export default async function runAutorunExecutor(
4455 await executeProcess ( {
4556 command,
4657 args : [ ...positionals , ...args ] ,
47- ...( cwd ? { cwd } : { } ) ,
58+ ...( context . cwd ? { cwd : context . cwd } : { } ) ,
4859 } ) ;
4960 } catch ( error ) {
5061 logger . error ( stringifyError ( error ) ) ;
@@ -55,7 +66,6 @@ export default async function runAutorunExecutor(
5566 } ;
5667 }
5768 }
58-
5969 return {
6070 success : true ,
6171 command : formattedBinString ,
0 commit comments