From 6495e2814061950d4c2f702881c640f912db1a82 Mon Sep 17 00:00:00 2001 From: Alan Agius Date: Tue, 28 Jun 2022 13:17:15 +0200 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 | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/symbols.js b/symbols.js index 02ab257..dd8779c 100644 --- a/symbols.js +++ b/symbols.js @@ -1,8 +1,16 @@ 'use strict'; -const isHyper = typeof process !== 'undefined' && process.env.TERM_PROGRAM === 'Hyper'; -const isWindows = typeof process !== 'undefined' && process.platform === 'win32'; -const isLinux = typeof process !== 'undefined' && process.platform === 'linux'; +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 +71,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 });