Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/npm/cli.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRebecca Turner <turner@mikomi.org>2015-01-05 11:46:51 +0300
committerRebecca Turner <me@re-becca.org>2015-06-26 03:26:39 +0300
commit5b1d8c951a566b975b25be6c3b540ffc1ce6850a (patch)
tree0a1819691396586d1b531583ab4d83e5732bb9cb /node_modules/has-unicode
parent933a16f0d39a61b2c9400d084ca102206ec028a1 (diff)
has-unicode@1.0.0
Add to give better unicode defaults by interrogating the locale
Diffstat (limited to 'node_modules/has-unicode')
-rw-r--r--node_modules/has-unicode/.npmignore32
-rw-r--r--node_modules/has-unicode/LICENSE13
-rw-r--r--node_modules/has-unicode/README.md39
-rw-r--r--node_modules/has-unicode/index.js18
-rw-r--r--node_modules/has-unicode/package.json36
-rw-r--r--node_modules/has-unicode/test/index.js26
6 files changed, 164 insertions, 0 deletions
diff --git a/node_modules/has-unicode/.npmignore b/node_modules/has-unicode/.npmignore
new file mode 100644
index 000000000..7e17cf19b
--- /dev/null
+++ b/node_modules/has-unicode/.npmignore
@@ -0,0 +1,32 @@
+# Logs
+logs
+*.log
+
+# Runtime data
+pids
+*.pid
+*.seed
+
+# Directory for instrumented libs generated by jscoverage/JSCover
+lib-cov
+
+# Coverage directory used by tools like istanbul
+coverage
+
+# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
+.grunt
+
+# Compiled binary addons (http://nodejs.org/api/addons.html)
+build/Release
+
+# Dependency directory
+# Commenting this out is preferred by some people, see
+# https://www.npmjs.org/doc/misc/npm-faq.html#should-i-check-my-node_modules-folder-into-git-
+node_modules
+
+# Users Environment Variables
+.lock-wscript
+
+# Editor temp files
+*~
+.#*
diff --git a/node_modules/has-unicode/LICENSE b/node_modules/has-unicode/LICENSE
new file mode 100644
index 000000000..e75605296
--- /dev/null
+++ b/node_modules/has-unicode/LICENSE
@@ -0,0 +1,13 @@
+Copyright (c) 2014, Rebecca Turner <me@re-becca.org>
+
+Permission to use, copy, modify, and/or distribute this software for any
+purpose with or without fee is hereby granted, provided that the above
+copyright notice and this permission notice appear in all copies.
+
+THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
diff --git a/node_modules/has-unicode/README.md b/node_modules/has-unicode/README.md
new file mode 100644
index 000000000..4393106fd
--- /dev/null
+++ b/node_modules/has-unicode/README.md
@@ -0,0 +1,39 @@
+has-unicode
+===========
+
+Try to guess if your terminal supports unicode
+
+```javascript
+var hasUnicode = require("has-unicode")
+
+if (hasUnicode()) {
+ // the terminal probably has unicode support
+}
+```
+```javascript
+var hasUnicode = require("has-unicode").tryHarder
+hasUnicode(function(unicodeSupported) {
+ if (unicodeSupported) {
+ // the terminal probably has unicode support
+ }
+})
+```
+
+## Detecting Unicode
+
+What we actually detect is UTF-8 support, as that's what Node itself supports.
+If you have a UTF-16 locale then you won't be detected as unicode capable.
+
+### Windows
+
+Since at least Windows 7, `cmd` and `powershell` have been unicode capable.
+As such, we report any Windows installation as unicode capable.
+
+
+### Unix Like Operating Systems
+
+We look at the environment variables `LC_ALL`, `LC_CTYPE`, and `LANG` in
+that order. For `LC_ALL` and `LANG`, it looks for `.UTF-8` in the value.
+For `LC_CTYPE` it looks to see if the value is `UTF-8`. This is sufficient
+for most POSIX systems. While locale data can be put in `/etc/locale.conf`
+as well, AFAIK it's always copied into the environment.
diff --git a/node_modules/has-unicode/index.js b/node_modules/has-unicode/index.js
new file mode 100644
index 000000000..edceb7030
--- /dev/null
+++ b/node_modules/has-unicode/index.js
@@ -0,0 +1,18 @@
+"use strict"
+var os = require("os")
+var child_process = require("child_process")
+
+var hasUnicode = module.exports = function () {
+ // Supported Win32 platforms (>XP) support unicode in the console, though
+ // font support isn't fantastic.
+ if (os.type() == "Windows_NT") { return true }
+
+ var isUTF8 = /[.]UTF-8/
+ if (isUTF8.test(process.env.LC_ALL)
+ || process.env.LC_CTYPE == 'UTF-8'
+ || isUTF8.test(process.env.LANG)) {
+ return true
+ }
+
+ return false
+}
diff --git a/node_modules/has-unicode/package.json b/node_modules/has-unicode/package.json
new file mode 100644
index 000000000..a56511ac6
--- /dev/null
+++ b/node_modules/has-unicode/package.json
@@ -0,0 +1,36 @@
+{
+ "name": "has-unicode",
+ "version": "1.0.0",
+ "description": "Try to guess if your terminal supports unicode",
+ "main": "index.js",
+ "scripts": {
+ "test": "tap test/*.js"
+ },
+ "repository": {
+ "type": "git",
+ "url": "https://github.com/iarna/has-unicode"
+ },
+ "keywords": [
+ "unicode",
+ "terminal"
+ ],
+ "author": {
+ "name": "Rebecca Turner",
+ "email": "me@re-becca.org"
+ },
+ "license": "ISC",
+ "bugs": {
+ "url": "https://github.com/iarna/has-unicode/issues"
+ },
+ "homepage": "https://github.com/iarna/has-unicode",
+ "devDependencies": {
+ "require-inject": "^1.1.1",
+ "tap": "^0.4.13"
+ },
+ "readme": "has-unicode\n===========\n\nTry to guess if your terminal supports unicode\n\n```javascript\nvar hasUnicode = require(\"has-unicode\")\n\nif (hasUnicode()) {\n // the terminal probably has unicode support\n}\n```\n```javascript\nvar hasUnicode = require(\"has-unicode\").tryHarder\nhasUnicode(function(unicodeSupported) {\n if (unicodeSupported) {\n // the terminal probably has unicode support\n }\n})\n```\n\n## Detecting Unicode\n\nWhat we actually detect is UTF-8 support, as that's what Node itself supports.\nIf you have a UTF-16 locale then you won't be detected as unicode capable.\n\n### Windows\n\nSince at least Windows 7, `cmd` and `powershell` have been unicode capable.\nAs such, we report any Windows installation as unicode capable.\n\n\n### Unix Like Operating Systems\n\nWe look at the environment variables `LC_ALL`, `LC_CTYPE`, and `LANG` in\nthat order. For `LC_ALL` and `LANG`, it looks for `.UTF-8` in the value. \nFor `LC_CTYPE` it looks to see if the value is `UTF-8`. This is sufficient\nfor most POSIX systems. While locale data can be put in `/etc/locale.conf`\nas well, AFAIK it's always copied into the environment.\n\n",
+ "readmeFilename": "README.md",
+ "gitHead": "a8c3dcf3be5f0c8f8e26a3e7ffea7da24344a006",
+ "_id": "has-unicode@1.0.0",
+ "_shasum": "bac5c44e064c2ffc3b8fcbd8c71afe08f9afc8cc",
+ "_from": "has-unicode@*"
+}
diff --git a/node_modules/has-unicode/test/index.js b/node_modules/has-unicode/test/index.js
new file mode 100644
index 000000000..2394c14ef
--- /dev/null
+++ b/node_modules/has-unicode/test/index.js
@@ -0,0 +1,26 @@
+"use strict"
+var test = require("tap").test
+var requireInject = require("require-inject")
+
+test("Windows", function (t) {
+ t.plan(1)
+ var hasUnicode = requireInject("../index.js", {
+ os: { type: function () { return "Windows_NT" } }
+ })
+ t.is(hasUnicode(), true, "Windows is assumed to be unicode aware")
+})
+test("Unix Env", function (t) {
+ t.plan(3)
+ var hasUnicode = requireInject("../index.js", {
+ os: { type: function () { return "Linux" } },
+ child_process: { exec: function (cmd,cb) { cb(new Error("not available")) } }
+ })
+ process.env.LANG = "en_US.UTF-8"
+ process.env.LC_ALL = null
+ t.is(hasUnicode(), true, "Linux with a UTF8 language")
+ process.env.LANG = null
+ process.env.LC_ALL = "en_US.UTF-8"
+ t.is(hasUnicode(), true, "Linux with UTF8 locale")
+ process.env.LC_ALL = null
+ t.is(hasUnicode(), false, "Linux without UTF8 language or locale")
+})