|
9 | 9 | } from '@nx/devkit'; |
10 | 10 | import { libraryGenerator } from '@nx/js'; |
11 | 11 | import type { LibraryGeneratorSchema } from '@nx/js/src/generators/library/schema'; |
12 | | -import path from 'node:path'; |
| 12 | +import * as path from 'node:path'; |
13 | 13 | import { createTreeWithEmptyWorkspace } from 'nx/src/generators/testing-utils/create-tree-with-empty-workspace'; |
14 | | -import { executeProcess } from '@code-pushup/utils'; |
| 14 | +import { executeProcess } from '@code-pushup/test-utils'; |
15 | 15 |
|
16 | 16 | export function executorContext< |
17 | 17 | T extends { projectName: string; cwd?: string }, |
@@ -95,11 +95,29 @@ export async function nxShowProjectJson<T extends ProjectConfiguration>( |
95 | 95 | cwd: string, |
96 | 96 | project: string, |
97 | 97 | ) { |
98 | | - const { code, stderr, stdout } = await executeProcess({ |
99 | | - command: 'npx', |
100 | | - args: ['nx', 'show', `project --json ${project}`], |
101 | | - cwd, |
102 | | - }); |
| 98 | + try { |
| 99 | + const { stderr, stdout } = await executeProcess({ |
| 100 | + command: 'npx', |
| 101 | + args: ['nx', 'show', 'project', project, '--json'], |
| 102 | + cwd, |
| 103 | + }); |
103 | 104 |
|
104 | | - return { code, stderr, projectJson: JSON.parse(stdout) as T }; |
| 105 | + return { |
| 106 | + code: 0, |
| 107 | + stderr, |
| 108 | + projectJson: JSON.parse(stdout) as T, |
| 109 | + }; |
| 110 | + } catch (error: unknown) { |
| 111 | + const execError = error as { |
| 112 | + code?: number | string | null; |
| 113 | + stderr?: string; |
| 114 | + stdout?: string; |
| 115 | + message?: string; |
| 116 | + }; |
| 117 | + return { |
| 118 | + code: typeof execError.code === 'number' ? execError.code : 1, |
| 119 | + stderr: execError.stderr ?? execError.message ?? String(error), |
| 120 | + projectJson: JSON.parse('{}'), |
| 121 | + }; |
| 122 | + } |
105 | 123 | } |
0 commit comments