Skip to content

Commit 3eea116

Browse files
committed
feat(plugin-inquirer): add figures symbols
1 parent 4625f9d commit 3eea116

3 files changed

Lines changed: 38 additions & 22 deletions

File tree

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
import process from "node:process";
2+
3+
/**
4+
* @description check the term is support unicode
5+
*/
6+
export const isUnicodeSupport = () => {
7+
if (process.platform !== "win32") {
8+
return process.env.TERM !== "linux"; // Linux console (kernel)
9+
}
10+
11+
return (
12+
Boolean(process.env.CI) ||
13+
Boolean(process.env.WT_SESSION) || // Windows Terminal
14+
process.env.ConEmuTask === "{cmd::Cmder}" || // ConEmu and cmder
15+
process.env.TERM_PROGRAM === "vscode" ||
16+
process.env.TERM === "xterm-256color" ||
17+
process.env.TERM === "alacritty" ||
18+
process.env.TERMINAL_EMULATOR === "JetBrains-JediTerm"
19+
);
20+
};
21+
22+
const mainSymbols = {
23+
pointer: "❯",
24+
radioOn: "◉",
25+
radioOff: "◯"
26+
};
27+
28+
const fallbackSymbols = {
29+
pointer: ">",
30+
radioOn: "(*)",
31+
radioOff: "( )"
32+
};
33+
34+
export const figures = isUnicodeSupport() ? mainSymbols : fallbackSymbols;
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
export * from "./inquirer";
1+
export * from "./figure";
22
export * from "./style";
33
export * from "./fuzzy";

‎packages/@cz-git/plugin-inquirer/src/shared/utils/inquirer.ts‎

Lines changed: 3 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -4,28 +4,9 @@
44
* @license MIT
55
*/
66

7-
import process from "node:process";
7+
import type Separator from "inquirer/lib/objects/separator";
88
import type { ChoiceType } from "../types";
99

10-
/**
11-
* @description check the term is support unicode
12-
*/
13-
export const isUnicodeSupport = () => {
14-
if (process.platform !== "win32") {
15-
return process.env.TERM !== "linux"; // Linux console (kernel)
16-
}
17-
18-
return (
19-
Boolean(process.env.CI) ||
20-
Boolean(process.env.WT_SESSION) || // Windows Terminal
21-
process.env.ConEmuTask === "{cmd::Cmder}" || // ConEmu and cmder
22-
process.env.TERM_PROGRAM === "vscode" ||
23-
process.env.TERM === "xterm-256color" ||
24-
process.env.TERM === "alacritty" ||
25-
process.env.TERMINAL_EMULATOR === "JetBrains-JediTerm"
26-
);
27-
};
28-
2910
/**
3011
* @description: check the target is Promise
3112
*/
@@ -36,4 +17,5 @@ export const isPromise = (target: any) => {
3617
/**
3718
* @description: check choice is selectable
3819
*/
39-
export const isSelectable = (choice: ChoiceType) => choice.type !== "separator" && !choice.disabled;
20+
export const isSelectable = (choice: ChoiceType<Separator["type"]>) =>
21+
choice.type !== "separator" && !choice.disabled;

0 commit comments

Comments
 (0)