Skip to content

Commit 3aedacf

Browse files
author
John Doe
committed
refactor: revert changes
1 parent 241df6a commit 3aedacf

File tree

1 file changed

+7
-20
lines changed
  • testing/test-nx-utils/src/lib/utils

1 file changed

+7
-20
lines changed

testing/test-nx-utils/src/lib/utils/nx.ts

Lines changed: 7 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,9 @@ import {
99
} from '@nx/devkit';
1010
import { libraryGenerator } from '@nx/js';
1111
import type { LibraryGeneratorSchema } from '@nx/js/src/generators/library/schema';
12-
import { execFile } from 'node:child_process';
1312
import path from 'node:path';
14-
import { promisify } from 'node:util';
1513
import { createTreeWithEmptyWorkspace } from 'nx/src/generators/testing-utils/create-tree-with-empty-workspace';
16-
17-
const execFileAsync = promisify(execFile);
14+
import { executeProcess } from '@code-pushup/utils';
1815

1916
export function executorContext<
2017
T extends { projectName: string; cwd?: string },
@@ -85,21 +82,11 @@ export async function nxShowProjectJson<T extends ProjectConfiguration>(
8582
cwd: string,
8683
project: string,
8784
) {
88-
try {
89-
const { stdout, stderr } = await execFileAsync(
90-
'npx',
91-
['nx', 'show', 'project', project, '--json'],
92-
{ cwd },
93-
);
85+
const { code, stderr, stdout } = await executeProcess({
86+
command: 'npx',
87+
args: ['nx', 'show', `project --json ${project}`],
88+
cwd,
89+
});
9490

95-
return { code: 0, stderr, projectJson: JSON.parse(stdout) as T };
96-
} catch (error) {
97-
const execError = error as { code?: number; stderr?: string };
98-
const fallbackProject = { name: project, root: '' };
99-
return {
100-
code: execError.code ?? 1,
101-
stderr: execError.stderr ?? String(error),
102-
projectJson: fallbackProject as T,
103-
};
104-
}
91+
return { code, stderr, projectJson: JSON.parse(stdout) as T };
10592
}

0 commit comments

Comments
 (0)