File tree Expand file tree Collapse file tree 2 files changed +13
-26
lines changed Expand file tree Collapse file tree 2 files changed +13
-26
lines changed Original file line number Diff line number Diff line change 1
- import { exec } from 'node:child_process' ;
2
1
import path from 'node:path' ;
3
2
import { fileURLToPath } from 'node:url' ;
3
+ import { rslibBuild } from '@e2e/helper' ;
4
4
5
5
const __filename = fileURLToPath ( import . meta. url ) ;
6
6
const __dirname = path . dirname ( __filename ) ;
7
7
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
-
28
8
export function getCwdByExample ( exampleName : string ) {
29
9
return path . join ( __dirname , '../examples' , exampleName ) ;
30
10
}
11
+
12
+ export { rslibBuild } ;
Original file line number Diff line number Diff line change @@ -136,6 +136,15 @@ export async function getResults(
136
136
} ;
137
137
}
138
138
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
+
139
148
export async function buildAndGetResults (
140
149
fixturePath : string ,
141
150
type : 'all' ,
@@ -152,11 +161,7 @@ export async function buildAndGetResults(
152
161
fixturePath : string ,
153
162
type : 'js' | 'dts' | 'css' | 'all' = 'js' ,
154
163
) {
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 ) ;
160
165
const {
161
166
origin : { bundlerConfigs, rsbuildConfig } ,
162
167
} = await rsbuildInstance . inspectConfig ( { verbose : true } ) ;
You can’t perform that action at this time.
0 commit comments