blob: 090af2af40771eb7db13b3a20ebf30c4343bc428 [file] [log] [blame]
Leo Repp58b9f112021-11-22 11:57:47 +01001'use strict';
2var objectAssign = require('object-assign');
3var escapeStringRegexp = require('escape-string-regexp');
4var platform = process.platform;
5
6var main = {
7 tick: '✔',
8 cross: '✖',
9 star: '★',
10 square: '▇',
11 squareSmall: '◻',
12 squareSmallFilled: '◼',
13 play: '▶',
14 circle: '◯',
15 circleFilled: '◉',
16 circleDotted: '◌',
17 circleDouble: '◎',
18 circleCircle: 'ⓞ',
19 circleCross: 'ⓧ',
20 circlePipe: 'Ⓘ',
21 circleQuestionMark: '?⃝',
22 bullet: '●',
23 dot: '․',
24 line: '─',
25 ellipsis: '…',
26 pointer: '❯',
27 pointerSmall: '›',
28 info: 'ℹ',
29 warning: '⚠',
30 hamburger: '☰',
31 smiley: '㋡',
32 mustache: '෴',
33 heart: '♥',
34 arrowUp: '↑',
35 arrowDown: '↓',
36 arrowLeft: '←',
37 arrowRight: '→',
38 radioOn: '◉',
39 radioOff: '◯',
40 checkboxOn: '☒',
41 checkboxOff: '☐',
42 checkboxCircleOn: 'ⓧ',
43 checkboxCircleOff: 'Ⓘ',
44 questionMarkPrefix: '?⃝',
45 oneHalf: '½',
46 oneThird: '⅓',
47 oneQuarter: '¼',
48 oneFifth: '⅕',
49 oneSixth: '⅙',
50 oneSeventh: '⅐',
51 oneEighth: '⅛',
52 oneNinth: '⅑',
53 oneTenth: '⅒',
54 twoThirds: '⅔',
55 twoFifths: '⅖',
56 threeQuarters: '¾',
57 threeFifths: '⅗',
58 threeEighths: '⅜',
59 fourFifths: '⅘',
60 fiveSixths: '⅚',
61 fiveEighths: '⅝',
62 sevenEighths: '⅞'
63};
64
65var win = {
66 tick: '√',
67 cross: '×',
68 star: '*',
69 square: '█',
70 squareSmall: '[ ]',
71 squareSmallFilled: '[█]',
72 play: '►',
73 circle: '( )',
74 circleFilled: '(*)',
75 circleDotted: '( )',
76 circleDouble: '( )',
77 circleCircle: '(○)',
78 circleCross: '(×)',
79 circlePipe: '(│)',
80 circleQuestionMark: '(?)',
81 bullet: '*',
82 dot: '.',
83 line: '─',
84 ellipsis: '...',
85 pointer: '>',
86 pointerSmall: '»',
87 info: 'i',
88 warning: '‼',
89 hamburger: '≡',
90 smiley: '☺',
91 mustache: '┌─┐',
92 heart: main.heart,
93 arrowUp: main.arrowUp,
94 arrowDown: main.arrowDown,
95 arrowLeft: main.arrowLeft,
96 arrowRight: main.arrowRight,
97 radioOn: '(*)',
98 radioOff: '( )',
99 checkboxOn: '[×]',
100 checkboxOff: '[ ]',
101 checkboxCircleOn: '(×)',
102 checkboxCircleOff: '( )',
103 questionMarkPrefix: '?',
104 oneHalf: '1/2',
105 oneThird: '1/3',
106 oneQuarter: '1/4',
107 oneFifth: '1/5',
108 oneSixth: '1/6',
109 oneSeventh: '1/7',
110 oneEighth: '1/8',
111 oneNinth: '1/9',
112 oneTenth: '1/10',
113 twoThirds: '2/3',
114 twoFifths: '2/5',
115 threeQuarters: '3/4',
116 threeFifths: '3/5',
117 threeEighths: '3/8',
118 fourFifths: '4/5',
119 fiveSixths: '5/6',
120 fiveEighths: '5/8',
121 sevenEighths: '7/8'
122};
123
124if (platform === 'linux') {
125 // the main one doesn't look that good on Ubuntu
126 main.questionMarkPrefix = '?';
127}
128
129var figures = platform === 'win32' ? win : main;
130
131var fn = function (str) {
132 if (figures === main) {
133 return str;
134 }
135
136 Object.keys(main).forEach(function (key) {
137 if (main[key] === figures[key]) {
138 return;
139 }
140
141 str = str.replace(new RegExp(escapeStringRegexp(main[key]), 'g'), figures[key]);
142 });
143
144 return str;
145};
146
147module.exports = objectAssign(fn, figures);