1- import  type  {  ParsedArgs  }  from  'citty' 
21import  {  existsSync ,  promises  as  fsp  }  from  'node:fs' 
32import  {  dirname ,  relative  }  from  'node:path' 
43import  process  from  'node:process' 
54
65import  {  setupDotenv  }  from  'c12' 
76import  {  defineCommand  }  from  'citty' 
87import  {  box ,  colors  }  from  'consola/utils' 
9- import  {  getArgs  as  getListhenArgs  }  from  'listhen/cli' 
108import  {  resolve  }  from  'pathe' 
119import  {  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
138143export  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