Skip to content

Commit 2b40c32

Browse files
committed
perf(preview): inline port description
1 parent 11f8bf7 commit 2b40c32

1 file changed

Lines changed: 9 additions & 20 deletions

File tree

‎packages/nuxi/src/commands/preview.ts‎

Lines changed: 9 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,10 @@
1-
importtype{ParsedArgs}from'citty'
21
import{existsSync,promisesasfsp}from'node:fs'
32
import{dirname,relative}from'node:path'
43
importprocessfrom'node:process'
54

65
import{setupDotenv}from'c12'
76
import{defineCommand}from'citty'
87
import{box,colors}from'consola/utils'
9-
import{getArgsasgetListhenArgs}from'listhen/cli'
108
import{resolve}from'pathe'
119
import{x}from'tinyexec'
1210

@@ -25,7 +23,11 @@ const command = defineCommand({
2523
...envNameArgs,
2624
...extendsArgs,
2725
...legacyRootDirArgs,
28-
port: { ...getListhenArgs().port,alias: ['p']},
26+
port: {
27+
type: 'string',
28+
description: 'Port to listen on',
29+
alias: ['p'],
30+
},
2931
...dotEnvArgs,
3032
},
3133
asyncrun(ctx){
@@ -115,7 +117,10 @@ const command = defineCommand({
115117
logger.error(`Cannot find \`${envFileName}\`.`)
116118
}
117119

118-
const{ port }=_resolveListenOptions(ctx.args)
120+
constport=ctx.args.port
121+
??process.env.NUXT_PORT
122+
??process.env.NITRO_PORT
123+
??process.env.PORT
119124

120125
logger.info(`Starting preview command: \`${nitroJSON.commands.preview}\``)
121126
const[command, ...commandArgs]=nitroJSON.commands.preview.split(' ')
@@ -136,19 +141,3 @@ const command = defineCommand({
136141
})
137142

138143
exportdefaultcommand
139-
140-
typeArgsT=Exclude<
141-
Awaited<typeofcommand.args>,
142-
undefined|((...args: unknown[])=>unknown)
143-
>
144-
145-
function_resolveListenOptions(args: ParsedArgs<ArgsT>){
146-
const_port=args.port
147-
??process.env.NUXT_PORT
148-
??process.env.NITRO_PORT
149-
??process.env.PORT
150-
151-
return{
152-
port: _port,
153-
}
154-
}

0 commit comments

Comments
 (0)