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

Function formatCommandStatus

packages/utils/src/lib/command.ts:12–41  ·  view source on GitHub ↗
(
  bin: string,
  options?: {
    env?: Record<string, string | number | boolean>;
    cwd?: string;
  },
  status: 'pending' | 'success' | 'failure' = 'pending',
)

Source from the content-addressed store, hash-verified

10 * @returns Formatted command string with colored status indicator.
11 */
12export function formatCommandStatus(
13 bin: string,
14 options?: {
15 env?: Record<string, string | number | boolean>;
16 cwd?: string;
17 },
18 status: 'pending' | 'success' | 'failure' = 'pending',
19): string {
20 const cwd = options?.cwd && path.relative(process.cwd(), options.cwd);
21 const cwdPrefix = cwd ? ansis.blue(cwd) : '';
22 const envString =
23 options?.env && Object.keys(options.env).length > 0
24 ? Object.entries(options.env).map(([key, value]) =>
25 ansis.gray(`${key}="${value}"`),
26 )
27 : [];
28 const statusColor =
29 status === 'pending'
30 ? ansis.blue('$')
31 : status === 'success'
32 ? ansis.green('$')
33 : ansis.red('$');
34
35 return [
36 ...(cwdPrefix ? [cwdPrefix] : []),
37 statusColor,
38 ...envString,
39 bin,
40 ].join(' ');
41}

Callers 3

commandMethod · 0.85
runCliExecutorFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected