mirror of
https://github.com/vitejs/vite.git
synced 2024-11-22 07:09:05 +00:00
fix: if host is specified check whether it is valid (#14013)
This commit is contained in:
parent
119c074604
commit
b1b816a6bb
@ -102,6 +102,16 @@ function cleanOptions<Options extends GlobalCLIOptions>(
|
||||
return ret
|
||||
}
|
||||
|
||||
/**
|
||||
* host may be a number (like 0), should convert to string
|
||||
*/
|
||||
const convertHost = (v: any) => {
|
||||
if (typeof v === 'number') {
|
||||
return String(v)
|
||||
}
|
||||
return v
|
||||
}
|
||||
|
||||
cli
|
||||
.option('-c, --config <file>', `[string] use specified config file`)
|
||||
.option('--base <path>', `[string] public base path (default: /)`)
|
||||
@ -116,7 +126,7 @@ cli
|
||||
.command('[root]', 'start dev server') // default command
|
||||
.alias('serve') // the command is called 'serve' in Vite's API
|
||||
.alias('dev') // alias to align with the script name
|
||||
.option('--host [host]', `[string] specify hostname`)
|
||||
.option('--host [host]', `[string] specify hostname`, { type: [convertHost] })
|
||||
.option('--port <port>', `[number] specify port`)
|
||||
.option('--https', `[boolean] use TLS + HTTP/2`)
|
||||
.option('--open [path]', `[boolean | string] open browser on startup`)
|
||||
@ -306,7 +316,7 @@ cli
|
||||
// preview
|
||||
cli
|
||||
.command('preview [root]', 'locally preview production build')
|
||||
.option('--host [host]', `[string] specify hostname`)
|
||||
.option('--host [host]', `[string] specify hostname`, { type: [convertHost] })
|
||||
.option('--port <port>', `[number] specify port`)
|
||||
.option('--strictPort', `[boolean] exit if specified port is already in use`)
|
||||
.option('--https', `[boolean] use TLS + HTTP/2`)
|
||||
|
Loading…
Reference in New Issue
Block a user