diff --git a/src/index.ts b/src/index.ts index 7b60cf8eb..b0cdfa06f 100644 --- a/src/index.ts +++ b/src/index.ts @@ -353,14 +353,11 @@ export async function build(_options: Options) { onSuccessProcess = exec(options.onSuccess, [], { nodeOptions: { shell: true, stdio: 'inherit' }, }) - - await onSuccessProcess - if ( - onSuccessProcess.exitCode && - onSuccessProcess.exitCode !== 0 - ) { - process.exitCode = onSuccessProcess.exitCode - } + onSuccessProcess.process?.on('exit', (code) => { + if (code && code !== 0) { + process.exitCode = code + } + }) } } }