@@ -10,7 +10,7 @@ export const umiBuild = async ({
1010} : ToolContext ) => {
1111 const BuildParams = z . object ( {
1212 ANALYZE : z
13- . union ( [ z . literal ( 1 ) , z . literal ( 0 ) ] )
13+ . literal ( 1 )
1414 . optional ( )
1515 . describe ( 'Analyze the bundle composition, disabled by default.' ) ,
1616 ANALYZE_PORT : z . number ( ) . optional ( ) . describe ( 'Custom port' ) ,
@@ -37,16 +37,25 @@ export const umiBuild = async ({
3737 description : `Build the ${ frameworkName } project.` ,
3838 parameters : BuildParams ,
3939 execute : async ( params ) => {
40- const { binPath } = parse ( root ) ;
41- const env = { ...process . env } ;
42- Object . entries ( params ) . forEach ( ( [ key , value ] ) => {
43- if ( value !== undefined ) {
44- env [ key ] = typeof value === 'number' ? value . toString ( ) : value ;
40+ try {
41+ const { binPath } = parse ( root ) ;
42+ const env = { ...process . env } ;
43+ for ( const [ key , value ] of Object . entries ( params ) ) {
44+ if ( value !== undefined && ( value === 1 || value === 'none' ) ) {
45+ env [ key ] = typeof value === 'number' ? value . toString ( ) : value ;
46+ }
4547 }
46- } ) ;
47-
48- const result = execSync ( `${ binPath } build` , { env, cwd : root } ) ;
49- return result . toString ( ) ;
48+ const result = execSync ( `${ binPath } build` , {
49+ env,
50+ cwd : root ,
51+ timeout : 5 * 60000 ,
52+ } ) ;
53+ return result . toString ( ) ;
54+ } catch ( error ) {
55+ throw new Error (
56+ `Build failed. Please check the error message above.\n${ error } ` ,
57+ ) ;
58+ }
5059 } ,
5160 } ) ;
5261} ;
0 commit comments