Codebase list node-ci-info / 7f0f547
Update upstream source from tag 'upstream/3.2.0+_cs4.2.0' Update to upstream version '3.2.0+~cs4.2.0' with Debian dir 6d40d8fe30979172a0350f3f1c5a523382bc6c8e Pirate Praveen 2 years ago
9 changed file(s) with 151 addition(s) and 0 deletion(s). Raw diff Collapse all Expand all
0 root = true
1
2 [*]
3 indent_style = tab
4 end_of_line = lf
5 charset = utf-8
6 trim_trailing_whitespace = true
7 insert_final_newline = true
8
9 [*.yml]
10 indent_style = space
11 indent_size = 2
0 package-lock=false
0 /**
1 Detect whether the terminal supports Unicode.
2
3 @example
4 ```
5 import isUnicodeSupported = require('is-unicode-supported');
6
7 isUnicodeSupported();
8 //=> true
9 ```
10 */
11 declare function isUnicodeSupported(): boolean;
12
13 export = isUnicodeSupported;
0 'use strict';
1
2 module.exports = () => {
3 if (process.platform !== 'win32') {
4 return true;
5 }
6
7 return Boolean(process.env.CI) ||
8 Boolean(process.env.WT_SESSION) || // Windows Terminal
9 process.env.TERM_PROGRAM === 'vscode' ||
10 process.env.TERM === 'xterm-256color' ||
11 process.env.TERM === 'alacritty';
12 };
0 import {expectType} from 'tsd';
1 import isUnicodeSupported = require('.');
2
3 expectType<boolean>(isUnicodeSupported());
0 MIT License
1
2 Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (https://sindresorhus.com)
3
4 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:
5
6 The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
7
8 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.
0 {
1 "name": "is-unicode-supported",
2 "version": "0.1.0",
3 "description": "Detect whether the terminal supports Unicode",
4 "license": "MIT",
5 "repository": "sindresorhus/is-unicode-supported",
6 "funding": "https://github.com/sponsors/sindresorhus",
7 "author": {
8 "name": "Sindre Sorhus",
9 "email": "sindresorhus@gmail.com",
10 "url": "https://sindresorhus.com"
11 },
12 "engines": {
13 "node": ">=10"
14 },
15 "scripts": {
16 "test": "xo && ava && tsd"
17 },
18 "files": [
19 "index.js",
20 "index.d.ts"
21 ],
22 "keywords": [
23 "terminal",
24 "unicode",
25 "detect",
26 "utf8",
27 "console",
28 "shell",
29 "support",
30 "supports",
31 "supported",
32 "check",
33 "detection"
34 ],
35 "devDependencies": {
36 "ava": "^2.4.0",
37 "tsd": "^0.14.0",
38 "xo": "^0.38.2"
39 }
40 }
0 # is-unicode-supported
1
2 > Detect whether the terminal supports Unicode
3
4 This can be useful to decide whether to use Unicode characters or fallback ASCII characters in command-line output.
5
6 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.
7
8 ## Install
9
10 ```
11 $ npm install is-unicode-supported
12 ```
13
14 ## Usage
15
16 ```js
17 const isUnicodeSupported = require('is-unicode-supported');
18
19 isUnicodeSupported();
20 //=> true
21 ```
22
23 ## API
24
25 ### isUnicodeSupported()
26
27 Returns a `boolean` for whether the terminal supports Unicode.
28
29 ## Related
30
31 - [is-interactive](https://github.com/sindresorhus/is-interactive) - Check if stdout or stderr is interactive
32 - [supports-color](https://github.com/chalk/supports-color) - Detect whether a terminal supports color
33 - [figures](https://github.com/sindresorhus/figures) - Unicode symbols with Windows fallbacks
34 - [log-symbols](https://github.com/sindresorhus/log-symbols) - Colored symbols for various log levels
0 import test from 'ava';
1 import isUnicodeSupported from './index.js';
2
3 test.serial('main', t => {
4 t.true(isUnicodeSupported());
5 });
6
7 test.serial('windows', t => {
8 delete process.env.CI;
9 delete process.env.TERM;
10 delete process.env.TERM_PROGRAM;
11
12 const originalPlatform = process.platform;
13
14 Object.defineProperty(process, 'platform', {value: 'win32'});
15 t.false(isUnicodeSupported());
16 process.env.WT_SESSION = '1';
17 t.true(isUnicodeSupported());
18
19 Object.defineProperty(process, 'platform', {value: originalPlatform});
20 delete process.env.WT_SESSION;
21 });