@@ -15,38 +15,35 @@ export function runCompile(ctx: {
15
15
projectPath : string ,
16
16
} ) {
17
17
return {
18
- compileRaw : compileProject ( ctx )
18
+ compileRaw : compileProject ( ctx ) !
19
19
}
20
20
}
21
21
22
22
export type RunCompileContext = ReturnType < typeof runCompile >
23
23
24
- async function compileProject ( ctx : { project : string , projectPath : string } ) {
25
- return new Promise < string > ( a => {
26
- cp . exec ( `pnpm ${ ctx . project } build` , ( _err , stdout ) => {
27
- a ( stdout )
28
- } )
29
- } )
30
- . then ( ( raw ) => {
31
- copyCommonJSPackageJson ( ctx )
32
- return raw
33
- } )
24
+ function compileProject ( ctx : { project : string , projectPath : string } ) {
25
+ try {
26
+ const raw = cp . execSync ( `pnpm ${ ctx . project } build` ) . toString ( )
27
+ copyCommonJSPackageJson ( ctx )
28
+ return raw
29
+ } catch ( e : any ) {
30
+ return e . stdout . toString ( )
31
+ }
34
32
}
35
33
36
34
export function processCompileResults ( { compileRaw, subjects, moduleTypes } : {
37
35
moduleTypes : string [ ]
38
36
} & RunCompileContext & TestSubjectsContext ) {
39
37
38
+ const results = extractCompileErrors ( compileRaw )
39
+ const compileErrors = results . flatMap ( result => result . importType === 'all'
40
+ ? subjects
41
+ . find ( s => s . name === result . subject ) ! . files
42
+ . map ( f => ( { ...result , importType : f . importType } ) )
43
+ : result )
44
+
40
45
return {
41
- compile : compileRaw
42
- . then ( extractCompileErrors )
43
- . then ( results => results . flatMap ( result => result . importType === 'all'
44
- ? subjects
45
- . find ( s => s . name === result . subject ) ! . files
46
- . map ( f => ( { ...result , importType : f . importType } ) )
47
- : result
48
- ) )
49
- . then ( compileErrors => buildCompileResults ( { compileErrors, moduleTypes, subjects } ) )
46
+ compile : buildCompileResults ( { compileErrors, moduleTypes, subjects } )
50
47
}
51
48
}
52
49
0 commit comments