From b595c2195ac32140e4b6979bc2f3b63d2da0c307 Mon Sep 17 00:00:00 2001 From: Alan Agius Date: Tue, 28 Jun 2022 11:27:33 +0000 Subject: [PATCH] fix: correctly display symbols in Windows terminals that support Unicode Nowadays more and more Windows terminals support Unicode. With this change we add support for this terminal and emulators as previously only `Hyper` was supported. We now added support for: - JetBrains terminal - VsCode terminal - Xterm - AlaCritty - Commander/ConEmu --- symbols.js | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/symbols.js b/symbols.js index 02ab257..4a369a3 100644 --- a/symbols.js +++ b/symbols.js @@ -1,8 +1,17 @@ 'use strict'; -const isHyper = typeof process !== 'undefined' && process.env.TERM_PROGRAM === 'Hyper'; -const isWindows = typeof process !== 'undefined' && process.platform === 'win32'; +const isWindows = + typeof process !== 'undefined' && process.platform === 'win32'; const isLinux = typeof process !== 'undefined' && process.platform === 'linux'; +const windowsHasUnicodeSupport = + process && + isWindows && + (process.env.TERM_PROGRAM === 'vscode' || + process.env.TERM_PROGRAM === 'Hyper' || + process.env.TERM === 'xterm-256color' || + process.env.TERM === 'alacritty' || + process.env.TERMINAL_EMULATOR === 'JetBrains-JediTerm' || + process.env.ConEmuTask === '{cmd::Cmder}'); const common = { ballotDisabled: '☒', @@ -63,7 +72,7 @@ const other = Object.assign({}, common, { warning: '⚠' }); -module.exports = (isWindows && !isHyper) ? windows : other; +module.exports = (isWindows && !windowsHasUnicodeSupport) ? windows : other; Reflect.defineProperty(module.exports, 'common', { enumerable: false, value: common }); Reflect.defineProperty(module.exports, 'windows', { enumerable: false, value: windows }); Reflect.defineProperty(module.exports, 'other', { enumerable: false, value: other });