Do not make select theme type when there's only one option
This commit is contained in:
parent
14f283cf49
commit
fcdbb04ea6
@ -26,8 +26,8 @@ export async function command(params: { cliCommandOptions: CliCommandOptions })
|
|||||||
|
|
||||||
console.log(chalk.cyan("Theme type:"));
|
console.log(chalk.cyan("Theme type:"));
|
||||||
|
|
||||||
const { value: themeType } = await cliSelect<ThemeType>({
|
const themeType = await (async () => {
|
||||||
values: [...THEME_TYPES].filter(themeType => {
|
const values = THEME_TYPES.filter(themeType => {
|
||||||
switch (themeType) {
|
switch (themeType) {
|
||||||
case "account":
|
case "account":
|
||||||
return buildContext.implementedThemeTypes.account.isImplemented;
|
return buildContext.implementedThemeTypes.account.isImplemented;
|
||||||
@ -35,11 +35,23 @@ export async function command(params: { cliCommandOptions: CliCommandOptions })
|
|||||||
return buildContext.implementedThemeTypes.login.isImplemented;
|
return buildContext.implementedThemeTypes.login.isImplemented;
|
||||||
}
|
}
|
||||||
assert<Equals<typeof themeType, never>>(false);
|
assert<Equals<typeof themeType, never>>(false);
|
||||||
})
|
});
|
||||||
|
|
||||||
|
assert(values.length > 0, "No theme is implemented in this project");
|
||||||
|
|
||||||
|
if (values.length === 1) {
|
||||||
|
return values[0];
|
||||||
|
}
|
||||||
|
|
||||||
|
const { value } = await cliSelect<ThemeType>({
|
||||||
|
values
|
||||||
}).catch(() => {
|
}).catch(() => {
|
||||||
process.exit(-1);
|
process.exit(-1);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
return value;
|
||||||
|
})();
|
||||||
|
|
||||||
if (
|
if (
|
||||||
themeType === "account" &&
|
themeType === "account" &&
|
||||||
(assert(buildContext.implementedThemeTypes.account.isImplemented),
|
(assert(buildContext.implementedThemeTypes.account.isImplemented),
|
||||||
|
@ -33,8 +33,8 @@ export async function command(params: { cliCommandOptions: CliCommandOptions })
|
|||||||
|
|
||||||
console.log(chalk.cyan("Theme type:"));
|
console.log(chalk.cyan("Theme type:"));
|
||||||
|
|
||||||
const { value: themeType } = await cliSelect<ThemeType>({
|
const themeType = await (async () => {
|
||||||
values: [...THEME_TYPES].filter(themeType => {
|
const values = THEME_TYPES.filter(themeType => {
|
||||||
switch (themeType) {
|
switch (themeType) {
|
||||||
case "account":
|
case "account":
|
||||||
return buildContext.implementedThemeTypes.account.isImplemented;
|
return buildContext.implementedThemeTypes.account.isImplemented;
|
||||||
@ -42,11 +42,23 @@ export async function command(params: { cliCommandOptions: CliCommandOptions })
|
|||||||
return buildContext.implementedThemeTypes.login.isImplemented;
|
return buildContext.implementedThemeTypes.login.isImplemented;
|
||||||
}
|
}
|
||||||
assert<Equals<typeof themeType, never>>(false);
|
assert<Equals<typeof themeType, never>>(false);
|
||||||
})
|
});
|
||||||
|
|
||||||
|
assert(values.length > 0, "No theme is implemented in this project");
|
||||||
|
|
||||||
|
if (values.length === 1) {
|
||||||
|
return values[0];
|
||||||
|
}
|
||||||
|
|
||||||
|
const { value } = await cliSelect<ThemeType>({
|
||||||
|
values
|
||||||
}).catch(() => {
|
}).catch(() => {
|
||||||
process.exit(-1);
|
process.exit(-1);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
return value;
|
||||||
|
})();
|
||||||
|
|
||||||
if (
|
if (
|
||||||
themeType === "account" &&
|
themeType === "account" &&
|
||||||
(assert(buildContext.implementedThemeTypes.account.isImplemented),
|
(assert(buildContext.implementedThemeTypes.account.isImplemented),
|
||||||
|
Loading…
x
Reference in New Issue
Block a user