mirror of
https://github.com/nuxt/nuxt.git
synced 2024-11-11 08:33:53 +00:00
refactor: simplify killNuxt
This commit is contained in:
parent
04e53b0f9f
commit
141a54a1e3
@ -9,17 +9,12 @@ const rootDir = resolve(__dirname, '..', 'fixtures/cli')
|
|||||||
const url = route => 'http://localhost:' + port + route
|
const url = route => 'http://localhost:' + port + route
|
||||||
const nuxtBin = resolve(__dirname, '..', '..', 'bin', 'nuxt')
|
const nuxtBin = resolve(__dirname, '..', '..', 'bin', 'nuxt')
|
||||||
|
|
||||||
const killNuxt = async (nuxtInt) => {
|
const close = async (nuxtInt) => {
|
||||||
let exitCode
|
nuxtInt.kill('SIGKILL')
|
||||||
nuxtInt.on('close', (code) => { exitCode = code })
|
|
||||||
nuxtInt.kill()
|
|
||||||
// Wait max 10s for the process to be killed
|
// Wait max 10s for the process to be killed
|
||||||
if (await waitUntil(() => exitCode !== undefined, 10)) {
|
if (await waitUntil(() => nuxtInt.killed, 10)) {
|
||||||
console.warn( // eslint-disable-line no-console
|
// eslint-disable-next-line no-console
|
||||||
`we were unable to automatically kill the child process with pid: ${
|
console.warn(`Unable to close process with pid: ${nuxtInt.pid}`)
|
||||||
nuxtInt.pid
|
|
||||||
}`
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -44,7 +39,7 @@ describe.skip.appveyor('cli', () => {
|
|||||||
stdout.indexOf('Compiled client') !==
|
stdout.indexOf('Compiled client') !==
|
||||||
stdout.lastIndexOf('Compiled client')
|
stdout.lastIndexOf('Compiled client')
|
||||||
)
|
)
|
||||||
await killNuxt(nuxtDev)
|
await close(nuxtDev)
|
||||||
})
|
})
|
||||||
|
|
||||||
test('nuxt start', async () => {
|
test('nuxt start', async () => {
|
||||||
@ -75,6 +70,6 @@ describe.skip.appveyor('cli', () => {
|
|||||||
const html = await rp(url('/'))
|
const html = await rp(url('/'))
|
||||||
expect(html).toMatch(('<div>CLI Test</div>'))
|
expect(html).toMatch(('<div>CLI Test</div>'))
|
||||||
|
|
||||||
await killNuxt(nuxtStart)
|
await close(nuxtStart)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
Loading…
Reference in New Issue
Block a user