@@ -99,7 +99,7 @@ export async function buildSingle(
9999 clean : ( ) => Promise < void > ,
100100) : Promise < ( ( ) => Promise < void > ) | undefined > {
101101 const { format : formats , dts, watch, onSuccess } = config
102- let onSuccessCleanup : ( ( ) => any ) | undefined
102+ let ab : AbortController | undefined
103103
104104 const { hooks, context } = await createHooks ( config )
105105
@@ -112,7 +112,7 @@ export async function buildSingle(
112112 const startTime = performance . now ( )
113113
114114 await hooks . callHook ( 'build:prepare' , context )
115- onSuccessCleanup ?. ( )
115+ ab ?. abort ( )
116116
117117 await clean ( )
118118
@@ -165,19 +165,19 @@ export async function buildSingle(
165165 prettyName ( config . name ) ,
166166 `${ first ? 'Build' : 'Rebuild' } complete in ${ green ( `${ Math . round ( performance . now ( ) - startTime ) } ms` ) } ` ,
167167 )
168-
168+ ab = new AbortController ( )
169169 if ( typeof onSuccess === 'string' ) {
170170 const p = exec ( onSuccess , [ ] , {
171171 nodeOptions : { shell : true , stdio : 'inherit' } ,
172+ signal : ab . signal ,
172173 } )
173174 p . then ( ( { exitCode } ) => {
174175 if ( exitCode ) {
175176 process . exitCode = exitCode
176177 }
177178 } )
178- onSuccessCleanup = ( ) => p . kill ( 'SIGTERM' )
179179 } else {
180- await onSuccess ?.( config )
180+ await onSuccess ?.( config , ab . signal )
181181 }
182182 }
183183}
0 commit comments