From d4bc0fb9f40b3e508b01ab8485e5a5b9b517da22 Mon Sep 17 00:00:00 2001 From: btea <2356281422@qq.com> Date: Mon, 4 Sep 2023 17:53:34 +0800 Subject: [PATCH] fix(cli): convert special base (#14283) --- packages/vite/src/node/cli.ts | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/packages/vite/src/node/cli.ts b/packages/vite/src/node/cli.ts index f6d3c9b6d6fd15..dbc8280a14876d 100644 --- a/packages/vite/src/node/cli.ts +++ b/packages/vite/src/node/cli.ts @@ -112,9 +112,21 @@ const convertHost = (v: any) => { return v } +/** + * base may be a number (like 0), should convert to empty string + */ +const convertBase = (v: any) => { + if (v === 0) { + return '' + } + return v +} + cli .option('-c, --config ', `[string] use specified config file`) - .option('--base ', `[string] public base path (default: /)`) + .option('--base ', `[string] public base path (default: /)`, { + type: [convertBase], + }) .option('-l, --logLevel ', `[string] info | warn | error | silent`) .option('--clearScreen', `[boolean] allow/disable clear screen when logging`) .option('-d, --debug [feat]', `[string | boolean] show debug logs`)