1
- import { exec } from 'tinyexec'
1
+ import { x } from 'tinyexec'
2
2
import { getRandomPort , waitForPort } from 'get-port-please'
3
3
import type { FetchOptions } from 'ofetch'
4
4
import { $fetch as _$fetch , fetch as _fetch } from 'ofetch'
5
- import * as _kit from '@nuxt/kit'
6
5
import { resolve } from 'pathe'
7
6
import { joinURL } from 'ufo'
8
7
import { useTestContext } from './context'
9
8
10
- // @ts -expect-error type cast kit default export
11
- const kit : typeof _kit = _kit . default || _kit
12
-
13
9
export interface StartServerOptions {
14
10
env ?: Record < string , unknown >
15
11
}
@@ -21,8 +17,8 @@ export async function startServer(options: StartServerOptions = {}) {
21
17
const port = ctx . options . port || ( await getRandomPort ( host ) )
22
18
ctx . url = `http://${ host } :${ port } /`
23
19
if ( ctx . options . dev ) {
24
- const nuxiCLI = await kit . resolvePath ( 'nuxi/cli' )
25
- ctx . serverProcess = exec ( nuxiCLI , [ '_dev' ] , {
20
+ ctx . serverProcess = x ( 'nuxi' , [ '_dev' ] , {
21
+ throwOnError : true ,
26
22
nodeOptions : {
27
23
cwd : ctx . nuxt ! . options . rootDir ,
28
24
stdio : 'inherit' ,
@@ -58,10 +54,11 @@ export async function startServer(options: StartServerOptions = {}) {
58
54
}
59
55
else {
60
56
const outputDir = ctx . nuxt ? ctx . nuxt . options . nitro . output ! . dir ! : ctx . options . nuxtConfig . nitro ! . output ! . dir !
61
- ctx . serverProcess = exec (
57
+ ctx . serverProcess = x (
62
58
'node' ,
63
59
[ resolve ( outputDir , 'server/index.mjs' ) ] ,
64
60
{
61
+ throwOnError : true ,
65
62
nodeOptions : {
66
63
stdio : 'inherit' ,
67
64
env : {
0 commit comments