Skip to content

Commit 2b40c32

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

File tree

1 file changed

+9
-20
lines changed

1 file changed

+9
-20
lines changed

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-
import type { ParsedArgs } from 'citty'
21
import { existsSync, promises as fsp } from 'node:fs'
32
import { dirname, relative } from 'node:path'
43
import process from 'node:process'
54

65
import { setupDotenv } from 'c12'
76
import { defineCommand } from 'citty'
87
import { box, colors } from 'consola/utils'
9-
import { getArgs as getListhenArgs } 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
async run(ctx) {
@@ -115,7 +117,10 @@ const command = defineCommand({
115117
logger.error(`Cannot find \`${envFileName}\`.`)
116118
}
117119

118-
const { port } = _resolveListenOptions(ctx.args)
120+
const port = 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
export default command
139-
140-
type ArgsT = Exclude<
141-
Awaited<typeof command.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)