MCPcopy Create free account
hub / github.com/TanStack/cli / stopChild

Function stopChild

packages/cli/tests-e2e/helpers.ts:142–174  ·  view source on GitHub ↗
(child: ReturnType<typeof spawn>)

Source from the content-addressed store, hash-verified

140}
141
142async function stopChild(child: ReturnType<typeof spawn>) {
143 if (child.killed || child.exitCode !== null) {
144 return
145 }
146
147 const killTree = (signal: NodeJS.Signals) => {
148 if (typeof child.pid === 'number') {
149 try {
150 process.kill(-child.pid, signal)
151 return
152 } catch {
153 // fall through to direct child kill
154 }
155 }
156 child.kill(signal)
157 }
158
159 killTree('SIGTERM')
160
161 await new Promise<void>((resolvePromise) => {
162 const timer = setTimeout(() => {
163 if (!child.killed && child.exitCode === null) {
164 killTree('SIGKILL')
165 }
166 resolvePromise()
167 }, 5_000)
168
169 child.once('close', () => {
170 clearTimeout(timer)
171 resolvePromise()
172 })
173 })
174}
175
176async function patchViteConfigForE2E(appDir: string) {
177 const viteConfigPath = join(appDir, 'vite.config.ts')

Callers 1

createAppFixtureFunction · 0.85

Calls 1

killTreeFunction · 0.85

Tested by

no test coverage detected