Skip to content

Commit 15418df

Browse files
author
John Doe
committed
refactor: wip
1 parent f4b8cdd commit 15418df

File tree

2 files changed

+14
-6
lines changed

2 files changed

+14
-6
lines changed

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

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,35 +23,42 @@ export default async function runAutorunExecutor(
2323
normalizedContext,
2424
);
2525
const { command: cliCommand } = terminalAndExecutorOptions;
26-
const { dryRun, verbose, bin, ...restArgs } = cliArgumentObject;
26+
const {
27+
dryRun,
28+
verbose,
29+
env: executorEnv,
30+
bin,
31+
...restArgs
32+
} = cliArgumentObject;
2733
const command = bin ? `node` : 'npx';
2834
const positionals = [
2935
bin ?? '@code-pushup/cli',
3036
...(cliCommand ? [cliCommand] : []),
3137
];
3238
const args = [...positionals, ...objectToCliArgs(restArgs)];
33-
const executorEnvVariables = {
39+
const env = {
40+
...executorEnv,
3441
...(verbose && { CP_VERBOSE: 'true' }),
3542
};
3643
const commandString = formatCommandStatus([command, ...args].join(' '), {
3744
cwd: context.cwd,
38-
env: executorEnvVariables,
45+
env,
3946
});
4047

4148
if (dryRun) {
4249
logger.warn(`DryRun execution of: ${commandString}`);
4350
} else {
4451
try {
45-
logger.debug(`With env vars: ${executorEnvVariables}`);
52+
logger.debug(`With env vars: ${env}`);
4653
await executeProcess({
4754
command,
4855
args,
4956
...(context.cwd ? { cwd: context.cwd } : {}),
50-
...(verbose
57+
...(Object.keys(env).length > 0
5158
? {
5259
env: {
5360
...process.env,
54-
...executorEnvVariables,
61+
...env,
5562
},
5663
}
5764
: {}),

packages/nx-plugin/src/executors/internal/types.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ export type Command =
3030
export type GlobalExecutorOptions = {
3131
command?: Command;
3232
bin?: string;
33+
env?: Record<string, string>;
3334
verbose?: boolean;
3435
config?: string;
3536
};

0 commit comments

Comments
 (0)