From a9bb9ebafde4fe20aba971599ad374a7f709e3fc Mon Sep 17 00:00:00 2001 From: JounQin Date: Thu, 8 Feb 2024 22:40:17 +0800 Subject: [PATCH] feat: support redirect to another option directly without value (#16038) --- src/main/core-options.evaluate.js | 2 +- src/main/normalize-options.js | 11 +++++++---- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/src/main/core-options.evaluate.js b/src/main/core-options.evaluate.js index a2add7167..3855a8b6c 100644 --- a/src/main/core-options.evaluate.js +++ b/src/main/core-options.evaluate.js @@ -17,7 +17,7 @@ import { * @property {OptionRangeInfo} [range] - for type int * @property {string} description * @property {string} [deprecated] - deprecated since version - * @property {OptionRedirectInfo} [redirect] - redirect deprecated option + * @property {OptionRedirectInfo | string} [redirect] - redirect deprecated option * @property {(value: any) => boolean} [exception] * @property {OptionChoiceInfo[]} [choices] - for type choice * @property {string} [cliName] diff --git a/src/main/normalize-options.js b/src/main/normalize-options.js index f96a5cf23..13d6dcb77 100644 --- a/src/main/normalize-options.js +++ b/src/main/normalize-options.js @@ -176,10 +176,13 @@ function optionInfoToSchema(optionInfo, { isCLI, optionInfos, FlagSchema }) { !value ? undefined : { - to: { - key: optionInfo.redirect.option, - value: optionInfo.redirect.value, - }, + to: + typeof optionInfo.redirect === "string" + ? optionInfo.redirect + : { + key: optionInfo.redirect.option, + value: optionInfo.redirect.value, + }, }; } /* c8 ignore stop */