pax_global_header00006660000000000000000000000064140243526450014517gustar00rootroot0000000000000052 comment=73d12afd9a8bb7efd747b18d8b8278d7e9364cfb is-unicode-supported-0.1.0/000077500000000000000000000000001402435264500155775ustar00rootroot00000000000000is-unicode-supported-0.1.0/.editorconfig000066400000000000000000000002571402435264500202600ustar00rootroot00000000000000root = true [*] indent_style = tab end_of_line = lf charset = utf-8 trim_trailing_whitespace = true insert_final_newline = true [*.yml] indent_style = space indent_size = 2 is-unicode-supported-0.1.0/.gitattributes000066400000000000000000000000231402435264500204650ustar00rootroot00000000000000* text=auto eol=lf is-unicode-supported-0.1.0/.github/000077500000000000000000000000001402435264500171375ustar00rootroot00000000000000is-unicode-supported-0.1.0/.github/workflows/000077500000000000000000000000001402435264500211745ustar00rootroot00000000000000is-unicode-supported-0.1.0/.github/workflows/main.yml000066400000000000000000000006641402435264500226510ustar00rootroot00000000000000name: CI on: - push - pull_request jobs: test: name: Node.js ${{ matrix.node-version }} runs-on: ubuntu-latest strategy: fail-fast: false matrix: node-version: - 14 - 12 - 10 steps: - uses: actions/checkout@v2 - uses: actions/setup-node@v1 with: node-version: ${{ matrix.node-version }} - run: npm install - run: npm test is-unicode-supported-0.1.0/.gitignore000066400000000000000000000000271402435264500175660ustar00rootroot00000000000000node_modules yarn.lock is-unicode-supported-0.1.0/.npmrc000066400000000000000000000000231402435264500167120ustar00rootroot00000000000000package-lock=false is-unicode-supported-0.1.0/index.d.ts000066400000000000000000000003631402435264500175020ustar00rootroot00000000000000/** Detect whether the terminal supports Unicode. @example ``` import isUnicodeSupported = require('is-unicode-supported'); isUnicodeSupported(); //=> true ``` */ declare function isUnicodeSupported(): boolean; export = isUnicodeSupported; is-unicode-supported-0.1.0/index.js000066400000000000000000000004711402435264500172460ustar00rootroot00000000000000'use strict'; module.exports = () => { if (process.platform !== 'win32') { return true; } return Boolean(process.env.CI) || Boolean(process.env.WT_SESSION) || // Windows Terminal process.env.TERM_PROGRAM === 'vscode' || process.env.TERM === 'xterm-256color' || process.env.TERM === 'alacritty'; }; is-unicode-supported-0.1.0/index.test-d.ts000066400000000000000000000001661402435264500204600ustar00rootroot00000000000000import {expectType} from 'tsd'; import isUnicodeSupported = require('.'); expectType(isUnicodeSupported()); is-unicode-supported-0.1.0/license000066400000000000000000000021351402435264500171450ustar00rootroot00000000000000MIT License Copyright (c) Sindre Sorhus (https://sindresorhus.com) Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. is-unicode-supported-0.1.0/package.json000066400000000000000000000013361402435264500200700ustar00rootroot00000000000000{ "name": "is-unicode-supported", "version": "0.1.0", "description": "Detect whether the terminal supports Unicode", "license": "MIT", "repository": "sindresorhus/is-unicode-supported", "funding": "https://github.com/sponsors/sindresorhus", "author": { "name": "Sindre Sorhus", "email": "sindresorhus@gmail.com", "url": "https://sindresorhus.com" }, "engines": { "node": ">=10" }, "scripts": { "test": "xo && ava && tsd" }, "files": [ "index.js", "index.d.ts" ], "keywords": [ "terminal", "unicode", "detect", "utf8", "console", "shell", "support", "supports", "supported", "check", "detection" ], "devDependencies": { "ava": "^2.4.0", "tsd": "^0.14.0", "xo": "^0.38.2" } } is-unicode-supported-0.1.0/readme.md000066400000000000000000000021501402435264500173540ustar00rootroot00000000000000# is-unicode-supported > Detect whether the terminal supports Unicode This can be useful to decide whether to use Unicode characters or fallback ASCII characters in command-line output. Note that the check is quite naive. It just assumes all non-Windows terminals support Unicode and hard-codes which Windows terminals that do support Unicode. However, I have been using this logic in some popular packages for years without problems. ## Install ``` $ npm install is-unicode-supported ``` ## Usage ```js const isUnicodeSupported = require('is-unicode-supported'); isUnicodeSupported(); //=> true ``` ## API ### isUnicodeSupported() Returns a `boolean` for whether the terminal supports Unicode. ## Related - [is-interactive](https://github.com/sindresorhus/is-interactive) - Check if stdout or stderr is interactive - [supports-color](https://github.com/chalk/supports-color) - Detect whether a terminal supports color - [figures](https://github.com/sindresorhus/figures) - Unicode symbols with Windows fallbacks - [log-symbols](https://github.com/sindresorhus/log-symbols) - Colored symbols for various log levels is-unicode-supported-0.1.0/test.js000066400000000000000000000010571402435264500171170ustar00rootroot00000000000000import test from 'ava'; import isUnicodeSupported from './index.js'; test.serial('main', t => { t.true(isUnicodeSupported()); }); test.serial('windows', t => { delete process.env.CI; delete process.env.TERM; delete process.env.TERM_PROGRAM; const originalPlatform = process.platform; Object.defineProperty(process, 'platform', {value: 'win32'}); t.false(isUnicodeSupported()); process.env.WT_SESSION = '1'; t.true(isUnicodeSupported()); Object.defineProperty(process, 'platform', {value: originalPlatform}); delete process.env.WT_SESSION; });