@@ -11,7 +11,7 @@ import execa from 'execa'
11
11
import kill from 'tree-kill'
12
12
import { version } from '../package.json'
13
13
import { createLogger , setSilent } from './log'
14
- import { NormalizedOptions , Format , Options } from './options'
14
+ import { NormalizedOptions , Format , Options , KILL_SIGNAL } from './options'
15
15
import { runEsbuild } from './esbuild'
16
16
import { shebang } from './plugins/shebang'
17
17
import { cjsSplitting } from './plugins/cjs-splitting'
@@ -34,15 +34,12 @@ export const defineConfig = (
34
34
) => MaybePromise < Options | Options [ ] > )
35
35
) => options
36
36
37
- const killProcess = ( {
38
- pid,
39
- signal = 'SIGTERM' ,
40
- } : {
41
- pid : number
42
- signal ?: string | number
43
- } ) =>
44
- new Promise < unknown > ( ( resolve ) => {
45
- kill ( pid , signal , resolve )
37
+ const killProcess = ( { pid, signal } : { pid : number ; signal : KILL_SIGNAL } ) =>
38
+ new Promise < void > ( ( resolve , reject ) => {
39
+ kill ( pid , signal , ( err ) => {
40
+ if ( err ) return reject ( err )
41
+ resolve ( )
42
+ } )
46
43
} )
47
44
48
45
const normalizeOptions = async (
@@ -207,6 +204,7 @@ export async function build(_options: Options) {
207
204
if ( onSuccessProcess ) {
208
205
await killProcess ( {
209
206
pid : onSuccessProcess . pid ,
207
+ signal : options . killSignal || 'SIGTERM' ,
210
208
} )
211
209
} else if ( onSuccessCleanup ) {
212
210
await onSuccessCleanup ( )
0 commit comments