|
1 | 1 | import { rm } from 'node:fs/promises'; |
2 | 2 | import path from 'node:path'; |
3 | | -import { |
4 | | - executeProcess, |
5 | | - readJsonFile, |
6 | | - stringifyError, |
7 | | -} from '@code-pushup/utils'; |
| 3 | +import { readJsonFile, stringifyError } from '@code-pushup/utils'; |
8 | 4 | import type { CommandContext } from '../context.js'; |
| 5 | +import { executeCliCommand } from '../exec.js'; |
9 | 6 |
|
10 | | -export async function runPrintConfig({ |
11 | | - bin, |
12 | | - config, |
13 | | - directory, |
14 | | - project, |
15 | | -}: CommandContext): Promise<unknown> { |
| 7 | +export async function runPrintConfig( |
| 8 | + context: CommandContext, |
| 9 | +): Promise<unknown> { |
16 | 10 | // unique file name per project so command can be run in parallel |
17 | | - const outputFile = ['code-pushup', 'config', project, 'json'] |
| 11 | + const outputFile = ['code-pushup', 'config', context.project, 'json'] |
18 | 12 | .filter(Boolean) |
19 | 13 | .join('.'); |
20 | 14 | const outputPath = |
21 | | - project && directory === process.cwd() |
| 15 | + context.project && context.directory === process.cwd() |
22 | 16 | ? // cache-friendly path for Nx projects (assuming {workspaceRoot}/.code-pushup/{projectName}) |
23 | | - path.join(process.cwd(), '.code-pushup', project, outputFile) |
| 17 | + path.join(process.cwd(), '.code-pushup', context.project, outputFile) |
24 | 18 | : // absolute path |
25 | | - path.resolve(directory, '.code-pushup', outputFile); |
| 19 | + path.resolve(context.directory, '.code-pushup', outputFile); |
26 | 20 |
|
27 | | - await executeProcess({ |
28 | | - command: bin, |
29 | | - args: [ |
30 | | - ...(config ? [`--config=${config}`] : []), |
31 | | - 'print-config', |
32 | | - `--output=${outputPath}`, |
33 | | - ], |
34 | | - cwd: directory, |
35 | | - }); |
| 21 | + await executeCliCommand(['print-config', `--output=${outputPath}`], context); |
36 | 22 |
|
37 | 23 | try { |
38 | 24 | const content = await readJsonFile(outputPath); |
|
0 commit comments