Skip to content

Commit bb3eadd

Browse files
committed
refactor: cleanup imports
1 parent c0236cb commit bb3eadd

File tree

6 files changed

+30
-18
lines changed

6 files changed

+30
-18
lines changed

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

Lines changed: 23 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -95,11 +95,28 @@ export async function nxShowProjectJson<T extends ProjectConfiguration>(
9595
cwd: string,
9696
project: string,
9797
) {
98-
const { 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', '--json', project],
102+
cwd,
103+
});
103104

104-
return { 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;
113+
stderr?: string;
114+
stdout?: string;
115+
};
116+
return {
117+
code: execError.code ?? 1,
118+
stderr: execError.stderr ?? String(error),
119+
projectJson: JSON.parse(execError.stdout ?? '{}') as T,
120+
};
121+
}
105122
}

tools/zod2md-jsdocs/src/lib/generators/configuration/generator.int.test.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ import {
66
} from '@nx/devkit';
77
import { createTreeWithEmptyWorkspace } from '@nx/devkit/testing';
88
import * as path from 'node:path';
9-
import { afterEach, describe, expect, it, vi } from 'vitest';
109
import { DEFAULT_ZOD2MD_CONFIG_FILE_NAME } from './constants.js';
1110
import { configurationGenerator } from './generator.js';
1211

tools/zod2md-jsdocs/src/lib/generators/configuration/tsconfig.unit.test.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import type * as devKit from '@nx/devkit';
22
import { createTreeWithEmptyWorkspace } from '@nx/devkit/testing';
33
import * as path from 'node:path';
4-
import { describe, expect, it } from 'vitest';
54
import { DEFAULT_ZOD2MD_CONFIG_FILE_NAME } from './constants.js';
65
import { addZod2MdTransformToTsConfig } from './tsconfig.js';
76

tools/zod2md-jsdocs/src/lib/generators/configuration/utils.unit.test.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import { describe, expect, it } from 'vitest';
21
import {
32
formatArrayToJSArray,
43
formatArrayToLinesOfJsString,

tools/zod2md-jsdocs/src/lib/generators/configuration/zod2md-config.unit.test.ts

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ import * as devKit from '@nx/devkit';
22
import { createTreeWithEmptyWorkspace } from '@nx/devkit/testing';
33
import * as path from 'node:path';
44
import stripAnsi from 'strip-ansi';
5-
import { afterEach, describe, expect, it } from 'vitest';
65
import { generateZod2MdConfig } from './zod2md-config.js';
76

87
describe('generateZod2MdConfig options', () => {
@@ -35,10 +34,10 @@ describe('generateZod2MdConfig options', () => {
3534
expect.any(String),
3635
expect.any(String),
3736
expect.objectContaining({
38-
entry: 'test-app/src/main.ts',
37+
entry: expect.pathToMatch('test-app/src/main.ts'),
3938
format: 'esm',
4039
title: 'App Types',
41-
output: 'test-app/docs/main.md',
40+
output: expect.pathToMatch('test-app/docs/main.md'),
4241
}),
4342
);
4443
});
@@ -95,14 +94,14 @@ describe('generateZod2MdConfig options', () => {
9594
expect.anything(),
9695
expect.any(String),
9796
expect.any(String),
98-
{
99-
entry: 'test-app/src/index.ts',
97+
expect.objectContaining({
98+
entry: expect.pathToMatch('test-app/src/index.ts'),
10099
format: 'esm',
101100
title: 'test-app reference',
102-
output: 'test-app/docs/test-app-reference.md',
101+
output: expect.pathToMatch('test-app/docs/test-app-reference.md'),
103102
transformName: undefined,
104-
tsconfig: 'test-app/tsconfig.lib.json',
105-
},
103+
tsconfig: expect.pathToMatch('test-app/tsconfig.lib.json'),
104+
}),
106105
);
107106
});
108107
});

tools/zod2md-jsdocs/src/lib/generators/sync-zod2md-setup/sync-zod2md-setup.unit.test.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import * as devkit from '@nx/devkit';
22
import { updateJson } from '@nx/devkit';
33
import type { NxProjectPackageJsonConfiguration } from 'nx/src/utils/package-json';
4-
import { expect } from 'vitest';
54
import { generateWorkspaceAndProject } from '@code-pushup/test-nx-utils';
65
import {
76
GENERATE_DOCS_TARGET_NAME,

0 commit comments

Comments
 (0)