From d5595a1f87d84cb759a8b3b8872bb9e5cb1faa0a Mon Sep 17 00:00:00 2001 From: ehmicky Date: Sun, 22 Oct 2023 21:31:41 +0100 Subject: [PATCH] Fix `circleQuestionMark` and `questionMarkPrefix` on Linux --- index.js | 19 ++----------------- test.js | 19 ++++++++++++------- 2 files changed, 14 insertions(+), 24 deletions(-) diff --git a/index.js b/index.js index 444c431..0e61869 100644 --- a/index.js +++ b/index.js @@ -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: '▒', @@ -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: '⚠', @@ -263,14 +250,12 @@ export const fallbackSymbols = { circleCircle: '(○)', circleCross: '(×)', circlePipe: '(│)', - circleQuestionMark: '(?)', radioOn: '(*)', radioOff: '( )', checkboxOn: '[×]', checkboxOff: '[ ]', checkboxCircleOn: '(×)', checkboxCircleOff: '( )', - questionMarkPrefix: '?', pointer: '>', triangleUpOutline: '∆', triangleLeft: '◄', diff --git a/test.js b/test.js index 00f12fb..9f47f4e 100644 --- a/test.js +++ b/test.js @@ -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() !== '');