Skip to content

Commit 563514a

Browse files
committed
chore: update
1 parent eece617 commit 563514a

File tree

2 files changed

+13
-26
lines changed

2 files changed

+13
-26
lines changed

benchmark/utils.ts

Lines changed: 3 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,12 @@
1-
import { exec } from 'node:child_process';
21
import path from 'node:path';
32
import { fileURLToPath } from 'node:url';
3+
import { rslibBuild } from '@e2e/helper';
44

55
const __filename = fileURLToPath(import.meta.url);
66
const __dirname = path.dirname(__filename);
77

8-
export function rslibBuild(cwd: string): Promise<void> {
9-
const childProcess = exec(
10-
'npx rslib build',
11-
{ cwd },
12-
(error, stdout, stderr) => {
13-
console.log(error, stderr, stdout);
14-
},
15-
);
16-
17-
return new Promise<void>((resolve) => {
18-
childProcess.on('exit', (code) => {
19-
if (code === 0) {
20-
resolve();
21-
} else {
22-
process.exit(1);
23-
}
24-
});
25-
});
26-
}
27-
288
export function getCwdByExample(exampleName: string) {
299
return path.join(__dirname, '../examples', exampleName);
3010
}
11+
12+
export { rslibBuild };

e2e/scripts/shared.ts

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,15 @@ export async function getResults(
136136
};
137137
}
138138

139+
export async function rslibBuild(fixturePath: string) {
140+
const rslibConfig = await loadConfig({
141+
cwd: fixturePath,
142+
});
143+
process.chdir(fixturePath);
144+
const rsbuildInstance = await build(rslibConfig);
145+
return { rsbuildInstance, rslibConfig };
146+
}
147+
139148
export async function buildAndGetResults(
140149
fixturePath: string,
141150
type: 'all',
@@ -152,11 +161,7 @@ export async function buildAndGetResults(
152161
fixturePath: string,
153162
type: 'js' | 'dts' | 'css' | 'all' = 'js',
154163
) {
155-
const rslibConfig = await loadConfig({
156-
cwd: fixturePath,
157-
});
158-
process.chdir(fixturePath);
159-
const rsbuildInstance = await build(rslibConfig);
164+
const { rsbuildInstance, rslibConfig } = await rslibBuild(fixturePath);
160165
const {
161166
origin: { bundlerConfigs, rsbuildConfig },
162167
} = await rsbuildInstance.inspectConfig({ verbose: true });

0 commit comments

Comments
 (0)