Skip to content

Commit 1fd918b

Browse files
author
John Doe
committed
refactor: fix env var logging
1 parent e5e8df0 commit 1fd918b

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

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

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ export default async function runCliExecutor(
2626
bin,
2727
...restArgs
2828
} = parseCliExecutorOptions(terminalAndExecutorOptions, normalizedContext);
29-
29+
// this sets `CP_VERBOSE=true` on process.env
3030
logger.setVerbose(verbose);
3131

3232
const command = bin ? `node` : 'npx';
@@ -35,27 +35,30 @@ export default async function runCliExecutor(
3535
...(cliCommand ? [cliCommand] : []),
3636
...objectToCliArgs(restArgs),
3737
];
38+
const loggedEnvVars = {
39+
...executorEnv,
40+
...(verbose && { CP_VERBOSE: 'true' }),
41+
};
3842
const commandString = formatCommandStatus([command, ...args].join(' '), {
3943
cwd: context.cwd,
40-
env: {
41-
...executorEnv,
42-
...(verbose && { CP_VERBOSE: 'true' }),
43-
},
44+
env: loggedEnvVars,
4445
});
4546

4647
if (dryRun) {
4748
logger.warn(`DryRun execution of: ${commandString}`);
4849
} else {
4950
try {
50-
logger.debug(`With env vars: ${executorEnv}`);
51+
logger.debug(`With env vars: ${loggedEnvVars}`);
5152
await executeProcess({
5253
command,
5354
args,
5455
...(context.cwd ? { cwd: context.cwd } : {}),
5556
...(executorEnv && Object.keys(executorEnv).length > 0
5657
? {
5758
env: {
59+
// if env is undefined, executeProcess extends process.env by default
5860
...process.env,
61+
// we don't pass `CP_VERBOSE=true` as it is handled inside logger.setVerbose
5962
...executorEnv,
6063
},
6164
}

0 commit comments

Comments
 (0)