MCPcopy Index your code
hub / github.com/code-pushup/cli / executeCliCommand

Function executeCliCommand

packages/ci/src/lib/cli/exec.ts:17–54  ·  view source on GitHub ↗
(
  args: string[],
  context: CommandContext,
  options?: { hasFormats: boolean },
)

Source from the content-addressed store, hash-verified

15 * @param options Optional information on whether all persist formats are set (if known)
16 */
17export async function executeCliCommand(
18 args: string[],
19 context: CommandContext,
20 options?: { hasFormats: boolean },
21): Promise<void> {
22 const { logOutputChunk, logOutputEnd, logSilencedOutput } =
23 createLogCallbacks(context);
24
25 const observer: ProcessObserver = {
26 onStdout: logOutputChunk,
27 onStderr: logOutputChunk,
28 onComplete: logOutputEnd,
29 onError: logOutputEnd,
30 };
31
32 const config: ProcessConfig = {
33 command: context.bin,
34 args: combineArgs(args, context, options),
35 cwd: context.directory,
36 observer,
37 silent: true,
38 };
39 const bin = serializeCommandWithArgs(config);
40
41 try {
42 await logger.command(bin, async () => {
43 try {
44 await executeProcess(config);
45 } catch (error) {
46 // ensure output of failed process is always logged for debugging
47 logSilencedOutput();
48 throw error;
49 }
50 });
51 } finally {
52 logger.newline();
53 }
54}
55
56function createLogCallbacks(context: Pick<CommandContext, 'silent'>) {
57 // eslint-disable-next-line functional/no-let

Callers 5

exec.unit.test.tsFile · 0.85
runMergeDiffsFunction · 0.85
runCollectFunction · 0.85
runPrintConfigFunction · 0.85
runCompareFunction · 0.85

Calls 7

serializeCommandWithArgsFunction · 0.90
executeProcessFunction · 0.90
createLogCallbacksFunction · 0.85
combineArgsFunction · 0.85
logSilencedOutputFunction · 0.85
commandMethod · 0.80
newlineMethod · 0.80

Tested by

no test coverage detected