Skip to content

Commit

Permalink
Improve emoji support detection (#7775)
Browse files Browse the repository at this point in the history
Co-authored-by: Agnieszka Gawrys <gawrysagnes@gmail.com>
  • Loading branch information
kidonng and AGawrys committed Mar 11, 2022
1 parent 083e530 commit 8442c62
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 4 deletions.
20 changes: 18 additions & 2 deletions packages/reporters/cli/src/emoji.js
@@ -1,7 +1,23 @@
// @flow strict-local

const supportsEmoji =
process.platform !== 'win32' || process.env.TERM === 'xterm-256color';
// From https://github.com/sindresorhus/is-unicode-supported/blob/8f123916d5c25a87c4f966dcc248b7ca5df2b4ca/index.js
// This package is ESM-only so it has to be vendored
function isUnicodeSupported() {
if (process.platform !== 'win32') {
return process.env.TERM !== 'linux'; // Linux console (kernel)
}

return (
Boolean(process.env.CI) ||
Boolean(process.env.WT_SESSION) || // Windows Terminal
process.env.ConEmuTask === '{cmd::Cmder}' || // ConEmu and cmder
process.env.TERM_PROGRAM === 'vscode' ||
process.env.TERM === 'xterm-256color' ||
process.env.TERM === 'alacritty'
);
}

const supportsEmoji = isUnicodeSupported();

// Fallback symbols for Windows from https://en.wikipedia.org/wiki/Code_page_437
export const progress: string = supportsEmoji ? '⏳' : '∞';
Expand Down
20 changes: 18 additions & 2 deletions packages/utils/create-react-app/src/emoji.js
@@ -1,7 +1,23 @@
// @flow strict-local

const supportsEmoji =
process.platform !== 'win32' || process.env.TERM === 'xterm-256color';
// From https://github.com/sindresorhus/is-unicode-supported/blob/8f123916d5c25a87c4f966dcc248b7ca5df2b4ca/index.js
// This package is ESM-only so it has to be vendored
function isUnicodeSupported() {
if (process.platform !== 'win32') {
return process.env.TERM !== 'linux'; // Linux console (kernel)
}

return (
Boolean(process.env.CI) ||
Boolean(process.env.WT_SESSION) || // Windows Terminal
process.env.ConEmuTask === '{cmd::Cmder}' || // ConEmu and cmder
process.env.TERM_PROGRAM === 'vscode' ||
process.env.TERM === 'xterm-256color' ||
process.env.TERM === 'alacritty'
);
}

const supportsEmoji = isUnicodeSupported();

// Fallback symbols for Windows from https://en.wikipedia.org/wiki/Code_page_437
export const progress: string = supportsEmoji ? '⏳' : '∞';
Expand Down

0 comments on commit 8442c62

Please sign in to comment.