From 8b59acd20dca5dd499ca0746a96468adf66eaa6e Mon Sep 17 00:00:00 2001 From: ehmicky Date: Sun, 29 Oct 2023 18:08:20 +0000 Subject: [PATCH] Fix `circleQuestionMark` and `questionMarkPrefix` on Linux (#98) --- 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() !== '');