Skip to content

Commit 7df895e

Browse files
committedJan 12, 2025
fix(e2e): use tinyexec to resolve nuxi binary
1 parent dcf038a commit 7df895e

File tree

1 file changed

+5
-8
lines changed

1 file changed

+5
-8
lines changed
 

‎src/core/server.ts

+5-8
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,11 @@
1-
import { exec } from 'tinyexec'
1+
import { x } from 'tinyexec'
22
import { getRandomPort, waitForPort } from 'get-port-please'
33
import type { FetchOptions } from 'ofetch'
44
import { $fetch as _$fetch, fetch as _fetch } from 'ofetch'
5-
import * as _kit from '@nuxt/kit'
65
import { resolve } from 'pathe'
76
import { joinURL } from 'ufo'
87
import { useTestContext } from './context'
98

10-
// @ts-expect-error type cast kit default export
11-
const kit: typeof _kit = _kit.default || _kit
12-
139
export interface StartServerOptions {
1410
env?: Record<string, unknown>
1511
}
@@ -21,8 +17,8 @@ export async function startServer(options: StartServerOptions = {}) {
2117
const port = ctx.options.port || (await getRandomPort(host))
2218
ctx.url = `http://${host}:${port}/`
2319
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,
2622
nodeOptions: {
2723
cwd: ctx.nuxt!.options.rootDir,
2824
stdio: 'inherit',
@@ -58,10 +54,11 @@ export async function startServer(options: StartServerOptions = {}) {
5854
}
5955
else {
6056
const outputDir = ctx.nuxt ? ctx.nuxt.options.nitro.output!.dir! : ctx.options.nuxtConfig.nitro!.output!.dir!
61-
ctx.serverProcess = exec(
57+
ctx.serverProcess = x(
6258
'node',
6359
[resolve(outputDir, 'server/index.mjs')],
6460
{
61+
throwOnError: true,
6562
nodeOptions: {
6663
stdio: 'inherit',
6764
env: {

0 commit comments

Comments
 (0)
Please sign in to comment.