Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix circleQuestionMark and questionMarkPrefix on Linux #98

Merged
merged 1 commit into from
Oct 29, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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