aboutsummaryrefslogtreecommitdiff
path: root/node_modules/supports-hyperlinks
diff options
context:
space:
mode:
Diffstat (limited to 'node_modules/supports-hyperlinks')
-rw-r--r--node_modules/supports-hyperlinks/browser.js8
-rw-r--r--node_modules/supports-hyperlinks/index.js95
-rw-r--r--node_modules/supports-hyperlinks/license9
-rw-r--r--node_modules/supports-hyperlinks/package.json48
-rw-r--r--node_modules/supports-hyperlinks/readme.md48
5 files changed, 208 insertions, 0 deletions
diff --git a/node_modules/supports-hyperlinks/browser.js b/node_modules/supports-hyperlinks/browser.js
new file mode 100644
index 0000000..b013630
--- /dev/null
+++ b/node_modules/supports-hyperlinks/browser.js
@@ -0,0 +1,8 @@
+'use strict';
+module.exports = {
+ stdin: false,
+ stderr: false,
+ supportsHyperlink: function () { // eslint-disable-line object-shorthand
+ return false;
+ }
+};
diff --git a/node_modules/supports-hyperlinks/index.js b/node_modules/supports-hyperlinks/index.js
new file mode 100644
index 0000000..02afb53
--- /dev/null
+++ b/node_modules/supports-hyperlinks/index.js
@@ -0,0 +1,95 @@
+'use strict';
+const supportsColor = require('supports-color');
+const hasFlag = require('has-flag');
+
+function parseVersion(versionString) {
+ if (/^\d{3,4}$/.test(versionString)) {
+ // Env var doesn't always use dots. example: 4601 => 46.1.0
+ const m = /(\d{1,2})(\d{2})/.exec(versionString);
+ return {
+ major: 0,
+ minor: parseInt(m[1], 10),
+ patch: parseInt(m[2], 10)
+ };
+ }
+
+ const versions = (versionString || '').split('.').map(n => parseInt(n, 10));
+ return {
+ major: versions[0],
+ minor: versions[1],
+ patch: versions[2]
+ };
+}
+
+function supportsHyperlink(stream) {
+ const {env} = process;
+
+ if ('FORCE_HYPERLINK' in env) {
+ return !(env.FORCE_HYPERLINK.length > 0 && parseInt(env.FORCE_HYPERLINK, 10) === 0);
+ }
+
+ if (hasFlag('no-hyperlink') || hasFlag('no-hyperlinks') || hasFlag('hyperlink=false') || hasFlag('hyperlink=never')) {
+ return false;
+ }
+
+ if (hasFlag('hyperlink=true') || hasFlag('hyperlink=always')) {
+ return true;
+ }
+
+ // If they specify no colors, they probably don't want hyperlinks.
+ if (!supportsColor.supportsColor(stream)) {
+ return false;
+ }
+
+ if (stream && !stream.isTTY) {
+ return false;
+ }
+
+ if (process.platform === 'win32') {
+ return false;
+ }
+
+ if ('NETLIFY' in env) {
+ return true;
+ }
+
+ if ('CI' in env) {
+ return false;
+ }
+
+ if ('TEAMCITY_VERSION' in env) {
+ return false;
+ }
+
+ if ('TERM_PROGRAM' in env) {
+ const version = parseVersion(env.TERM_PROGRAM_VERSION);
+
+ switch (env.TERM_PROGRAM) {
+ case 'iTerm.app':
+ if (version.major === 3) {
+ return version.minor >= 1;
+ }
+
+ return version.major > 3;
+ // No default
+ }
+ }
+
+ if ('VTE_VERSION' in env) {
+ // 0.50.0 was supposed to support hyperlinks, but throws a segfault
+ if (env.VTE_VERSION === '0.50.0') {
+ return false;
+ }
+
+ const version = parseVersion(env.VTE_VERSION);
+ return version.major > 0 || version.minor >= 50;
+ }
+
+ return false;
+}
+
+module.exports = {
+ supportsHyperlink,
+ stdout: supportsHyperlink(process.stdout),
+ stderr: supportsHyperlink(process.stderr)
+};
diff --git a/node_modules/supports-hyperlinks/license b/node_modules/supports-hyperlinks/license
new file mode 100644
index 0000000..32a380a
--- /dev/null
+++ b/node_modules/supports-hyperlinks/license
@@ -0,0 +1,9 @@
+MIT License
+
+Copyright (c) James Talmage <james@talmage.io> (github.com/jamestalmage)
+
+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.
diff --git a/node_modules/supports-hyperlinks/package.json b/node_modules/supports-hyperlinks/package.json
new file mode 100644
index 0000000..a8716bb
--- /dev/null
+++ b/node_modules/supports-hyperlinks/package.json
@@ -0,0 +1,48 @@
+{
+ "name": "supports-hyperlinks",
+ "version": "2.2.0",
+ "description": "Detect if your terminal emulator supports hyperlinks",
+ "license": "MIT",
+ "repository": "jamestalmage/supports-hyperlinks",
+ "author": {
+ "name": "James Talmage",
+ "email": "james@talmage.io",
+ "url": "github.com/jamestalmage"
+ },
+ "engines": {
+ "node": ">=8"
+ },
+ "scripts": {
+ "prepublishOnly": "npm run create-types",
+ "test": "xo && nyc ava",
+ "create-types": "tsc index.js --allowJs --declaration --emitDeclarationOnly"
+ },
+ "files": [
+ "index.js",
+ "browser.js"
+ ],
+ "browser": "browser.js",
+ "keywords": [
+ "link",
+ "terminal",
+ "hyperlink",
+ "cli"
+ ],
+ "dependencies": {
+ "has-flag": "^4.0.0",
+ "supports-color": "^7.0.0"
+ },
+ "devDependencies": {
+ "ava": "^2.2.0",
+ "codecov": "^3.5.0",
+ "nyc": "^14.1.1",
+ "typescript": "^3.7.2",
+ "xo": "^0.24.0"
+ },
+ "nyc": {
+ "reporter": [
+ "lcov",
+ "text"
+ ]
+ }
+}
diff --git a/node_modules/supports-hyperlinks/readme.md b/node_modules/supports-hyperlinks/readme.md
new file mode 100644
index 0000000..ec833ac
--- /dev/null
+++ b/node_modules/supports-hyperlinks/readme.md
@@ -0,0 +1,48 @@
+# supports-hyperlinks [![Build Status](https://travis-ci.org/jamestalmage/supports-hyperlinks.svg?branch=master)](https://travis-ci.org/jamestalmage/supports-hyperlinks) [![codecov](https://codecov.io/gh/jamestalmage/supports-hyperlinks/badge.svg?branch=master)](https://codecov.io/gh/jamestalmage/supports-hyperlinks?branch=master)
+
+> Detect whether a terminal emulator supports hyperlinks
+
+Terminal emulators are [starting to support hyperlinks](https://gist.github.com/egmontkob/eb114294efbcd5adb1944c9f3cb5feda). While many terminals have long detected URL's and linkified them, allowing you to Command-Click or Control-Click them to open a browser, you were forced to print the long unsightly URL's on the screen. As of spring 2017 [a few terminals](https://gist.github.com/egmontkob/eb114294efbcd5adb1944c9f3cb5feda) began supporting HTML like links, where the link text and destination could be specified separately.
+
+This module allows you to detect if hyperlinks are supported in the current Terminal.
+
+As this is a new development, we anticipate the list of supported Terminals to grow rapidly. Please open an issue or submit a PR as new Terminals implement support.
+
+## Install
+
+```
+$ npm install supports-hyperlinks
+```
+
+
+## Usage
+
+```js
+const supportsHyperlinks = require('supports-hyperlinks');
+
+if (supportsHyperlinks.stdout) {
+ console.log('Terminal stdout supports hyperlinks');
+}
+
+if (supportsHyperlinks.stderr) {
+ console.log('Terminal stderr supports hyperlinks');
+}
+```
+
+## API
+
+Returns an `Object` with a `stdout` and `stderr` property for testing either streams. Each property is a `boolean`, indicating whether or not hyperlinks are supported.
+
+## Info
+
+Obeys the `--no-hyperlinks`, `--hyperlink=always`, and `--hyperlink=never` CLI flags.
+
+Can be overridden by the user with the flags `--hyperlinks=always` and `--no-hyperlinks`. For situations where using those flags are not possible, add the environment variable `FORCE_HYPERLINK=1` to forcefully enable hyperlinks or `FORCE_HYPERLINK=0` to forcefully disable. The use of `FORCE_HYPERLINK` overrides all other hyperlink support checks.
+
+## Related
+
+ * [`hyperlinker`](https://github.com/jamestalmage/hyperlinker): Write hyperlinks for the Terminal.
+
+## License
+
+MIT © [James Talmage](https://github.com/jamestalmage)