Skip to content

Commit bd9d818

Browse files
committed
fix: kill sub-process for onSuccess
closes #364
1 parent 7c32a1d commit bd9d818

File tree

4 files changed

+20
-1
lines changed

4 files changed

+20
-1
lines changed

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,7 @@
9595
"semver": "catalog:prod",
9696
"tinyexec": "catalog:prod",
9797
"tinyglobby": "catalog:prod",
98+
"tree-kill": "catalog:prod",
9899
"unconfig": "catalog:prod"
99100
},
100101
"devDependencies": {

pnpm-lock.yaml

Lines changed: 12 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pnpm-workspace.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ catalogs:
4949
semver: ^7.7.2
5050
tinyexec: ^1.0.1
5151
tinyglobby: ^0.2.14
52+
tree-kill: ^1.2.2
5253
unconfig: ^7.3.2
5354

5455
ignoredBuiltDependencies:

src/index.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import {
99
type RolldownPluginOption,
1010
} from 'rolldown'
1111
import { exec } from 'tinyexec'
12+
import treeKill from 'tree-kill'
1213
import { attw } from './features/attw'
1314
import { cleanOutDir } from './features/clean'
1415
import { copy } from './features/copy'
@@ -172,14 +173,18 @@ export async function buildSingle(
172173
nodeOptions: {
173174
shell: true,
174175
stdio: 'inherit',
175-
signal: ab.signal,
176176
},
177177
})
178178
p.then(({ exitCode }) => {
179179
if (exitCode) {
180180
process.exitCode = exitCode
181181
}
182182
})
183+
ab.signal.addEventListener('abort', () => {
184+
if (typeof p.pid === 'number') {
185+
treeKill(p.pid)
186+
}
187+
})
183188
} else {
184189
await onSuccess?.(config, ab.signal)
185190
}

0 commit comments

Comments
 (0)