Skip to content

Commit 4af0dc3

Browse files
committed
fix(dev): honour a bare --profile flag
1 parent 672c101 commit 4af0dc3

2 files changed

Lines changed: 10 additions & 5 deletions

File tree

packages/nuxt-cli/src/commands/dev.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -177,9 +177,13 @@ const command = defineCommand({
177177
listenOverrides.port = takeover.port
178178
}
179179

180+
// `--profile` takes an optional value, so its presence rather than its
181+
// truthiness is what says the profiler was asked for.
182+
const profiling = ctx.args.profile !== undefined
183+
180184
// With `SO_REUSEPORT` an incoming fork can bind the port before this process
181185
// releases it, so a hard restart never leaves the port unserved.
182-
const reusePort = ctx.args.fork && !ctx.args.profile && await isReusePortSupported()
186+
const reusePort = ctx.args.fork && !profiling && await isReusePortSupported()
183187
listenOverrides.reusePort = reusePort
184188

185189
// The inspector belongs to whichever process is currently serving the app:
@@ -196,7 +200,7 @@ const command = defineCommand({
196200
})
197201

198202
// Disable forking when profiling to capture all activity in one process
199-
if (!ctx.args.fork || ctx.args.profile) {
203+
if (!ctx.args.fork || profiling) {
200204
setupShortcuts({ listener, close, onReady, restart: () => reload({ type: 'shortcut' }) })
201205
setupSignalHandlers(close)
202206
return {

packages/nuxt-cli/src/dev/index.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -130,12 +130,13 @@ export async function initialize(devContext: NuxtDevContext, ctx: InitializeOpti
130130
overrideEnv('development')
131131

132132
const profileArg = devContext.args.profile
133-
const perfValue = profileArg === 'verbose' ? true : profileArg ? 'quiet' : undefined
133+
const profiling = profileArg !== undefined
134+
const perfValue = profileArg === 'verbose' ? true : profiling ? 'quiet' : undefined
134135
const perfOverrides = perfValue
135136
? { debug: { perf: perfValue } } as NuxtConfig
136137
: {}
137138

138-
if (profileArg) {
139+
if (profiling) {
139140
await startCpuProfile()
140141
}
141142

@@ -192,7 +193,7 @@ export async function initialize(devContext: NuxtDevContext, ctx: InitializeOpti
192193
console.debug(`Dev server (internal) initialized in ${Date.now() - start}ms`)
193194
}
194195

195-
if (profileArg) {
196+
if (profiling) {
196197
for (const signal of [
197198
'exit',
198199
'SIGTERM' /* Graceful shutdown */,

0 commit comments

Comments
 (0)