Skip to content

Commit

Permalink
Fix circleQuestionMark and questionMarkPrefix on Linux (#98)
Browse files Browse the repository at this point in the history
  • Loading branch information
ehmicky authored Oct 29, 2023
1 parent 32fb096 commit 8b59acd
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 24 deletions.
19 changes: 2 additions & 17 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
import process from 'node:process';
import isUnicodeSupported from 'is-unicode-supported';

const {platform} = process;

const common = {
circleQuestionMark: '(?)',
questionMarkPrefix: '(?)',
square: '█',
squareDarkShade: '▓',
squareMediumShade: '▒',
Expand Down Expand Up @@ -200,18 +199,6 @@ const common = {

export const mainSymbols = {
...common,
// The main symbols for those do not look that good on Ubuntu.
...(
platform === 'linux'
? {
circleQuestionMark: '?⃝',
questionMarkPrefix: '?⃝',
}
: {
circleQuestionMark: '?',
questionMarkPrefix: '?',
}
),
tick: '✔',
info: 'ℹ',
warning: '⚠',
Expand Down Expand Up @@ -263,14 +250,12 @@ export const fallbackSymbols = {
circleCircle: '(○)',
circleCross: '(×)',
circlePipe: '(│)',
circleQuestionMark: '(?)',
radioOn: '(*)',
radioOff: '( )',
checkboxOn: '[×]',
checkboxOff: '[ ]',
checkboxCircleOn: '(×)',
checkboxCircleOff: '( )',
questionMarkPrefix: '?',
pointer: '>',
triangleUpOutline: '∆',
triangleLeft: '◄',
Expand Down
19 changes: 12 additions & 7 deletions test.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,19 +10,24 @@ test('figures', t => {
t.is(figures.tick, result('✔', '√'));
});

test('replaceSymbols()', t => {
test('mainSymbols', t => {
t.is(mainSymbols.tick, '✔');
});

test('fallbackSymbols', t => {
t.is(fallbackSymbols.tick, '√');
});

test('replaceSymbols() keep non-figures as is', t => {
t.is(replaceSymbols('foo'), 'foo');
t.is(replaceSymbols('?bar?'), '?bar?');
});

test('replaceSymbols() replace figures', t => {
t.is(replaceSymbols('✔ ✔ ✔'), result('✔ ✔ ✔', '√ √ √'));
t.is(replaceSymbols('✔ ✘\n★ ◼'), result('✔ ✘\n★ ◼', '√ ×\n✶ ■'));
t.is(replaceSymbols('✔ ✘ ★ ◼'), result('✔ ✘ ★ ◼', '√ × ✶ ■'));
});

test('mainSymbols and windowsSymbols', t => {
t.is(mainSymbols.tick, '✔');
t.is(fallbackSymbols.tick, '√');
});

test('figures are non-empty strings', t => {
for (const figure of Object.values(figures)) {
t.true(typeof figure === 'string' && figure.trim() !== '');
Expand Down

0 comments on commit 8b59acd

Please sign in to comment.