fix(start): execute Nitro preview commands faithfully · nuxt/cli@b80ed9c · GitHub
Skip to content

Commit b80ed9c

Browse files
committed
fix(start): execute Nitro preview commands faithfully
1 parent 0cf1306 commit b80ed9c

4 files changed

Lines changed: 102 additions & 2 deletions

File tree

‎packages/nuxt-cli/package.json‎

Lines changed: 1 addition & 0 deletions

‎packages/nuxt-cli/src/commands/preview.ts‎

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,14 @@ import process from 'node:process'
44

55
import { styleText } from 'node:util'
66
import { box, outro } from '@clack/prompts'
7+
import { tokenizeArgs } from 'args-tokenizer'
78
import { defineCommand } from 'citty'
89
import { resolve } from 'pathe'
910
import { x } from 'tinyexec'
1011

1112
import { loadKit } from '../utils/kit'
1213
import { logger } from '../utils/logger'
14+
import { withPrependedPath } from '../utils/path-env'
1315
import { relativeToProcess, resolveRootDir } from '../utils/paths'
1416
import { dotEnvArgs, envNameArgs, extendsArgs, logLevelArgs, rootDirArgs } from './_shared'
1517

@@ -153,14 +155,17 @@ const command = defineCommand({
153155

154156
outro(`Running ${styleText('cyan', previewCommand)} in ${styleText('cyan', relativeToProcess(outputPath))}`)
155157

156-
const [command, ...commandArgs] = previewCommand.trim().split(/\s+/) as [string, ...string[]]
158+
const [command, ...commandArgs] = tokenizeArgs(previewCommand) as [string, ...string[]]
157159
await x(command, commandArgs, {
158160
throwOnError: true,
159161
nodeOptions: {
160162
stdio: 'inherit',
161163
cwd: outputPath,
162164
env: {
163-
...process.env,
165+
...withPrependedPath(process.env, [
166+
resolve(outputPath, 'node_modules/.bin'),
167+
resolve(cwd, 'node_modules/.bin'),
168+
]),
164169
NUXT_PORT: port,
165170
NITRO_PORT: port,
166171
NUXT_HOST: host,
Lines changed: 86 additions & 0 deletions

‎pnpm-lock.yaml‎

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

0 commit comments

Comments
 (0)