supports-hyperlinks 2.3.0 → 3.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.d.ts +5 -0
- package/index.js +36 -14
- package/license +1 -1
- package/package.json +55 -46
- package/readme.md +2 -2
package/index.d.ts
ADDED
package/index.js
CHANGED
@@ -2,10 +2,14 @@
|
|
2
2
|
const supportsColor = require('supports-color');
|
3
3
|
const hasFlag = require('has-flag');
|
4
4
|
|
5
|
+
/**
|
6
|
+
@param {string} versionString
|
7
|
+
@returns {{ major: number, minor: number, patch: number }}
|
8
|
+
*/
|
5
9
|
function parseVersion(versionString) {
|
6
10
|
if (/^\d{3,4}$/.test(versionString)) {
|
7
11
|
// Env var doesn't always use dots. example: 4601 => 46.1.0
|
8
|
-
const m = /(\d{1,2})(\d{2})/.exec(versionString);
|
12
|
+
const m = /(\d{1,2})(\d{2})/.exec(versionString) || [];
|
9
13
|
return {
|
10
14
|
major: 0,
|
11
15
|
minor: parseInt(m[1], 10),
|
@@ -21,11 +25,23 @@ function parseVersion(versionString) {
|
|
21
25
|
};
|
22
26
|
}
|
23
27
|
|
28
|
+
/**
|
29
|
+
@param {{ isTTY?: boolean | undefined }} stream
|
30
|
+
@returns {boolean}
|
31
|
+
*/
|
24
32
|
function supportsHyperlink(stream) {
|
25
|
-
const {
|
26
|
-
|
27
|
-
|
28
|
-
|
33
|
+
const {
|
34
|
+
CI,
|
35
|
+
FORCE_HYPERLINK,
|
36
|
+
NETLIFY,
|
37
|
+
TEAMCITY_VERSION,
|
38
|
+
TERM_PROGRAM,
|
39
|
+
TERM_PROGRAM_VERSION,
|
40
|
+
VTE_VERSION
|
41
|
+
} = process.env;
|
42
|
+
|
43
|
+
if (FORCE_HYPERLINK) {
|
44
|
+
return !(FORCE_HYPERLINK.length > 0 && parseInt(FORCE_HYPERLINK, 10) === 0);
|
29
45
|
}
|
30
46
|
|
31
47
|
if (hasFlag('no-hyperlink') || hasFlag('no-hyperlinks') || hasFlag('hyperlink=false') || hasFlag('hyperlink=never')) {
|
@@ -37,7 +53,7 @@ function supportsHyperlink(stream) {
|
|
37
53
|
}
|
38
54
|
|
39
55
|
// Netlify does not run a TTY, it does not need `supportsColor` check
|
40
|
-
if (
|
56
|
+
if (NETLIFY) {
|
41
57
|
return true;
|
42
58
|
}
|
43
59
|
|
@@ -50,22 +66,27 @@ function supportsHyperlink(stream) {
|
|
50
66
|
return false;
|
51
67
|
}
|
52
68
|
|
69
|
+
// Windows Terminal
|
70
|
+
if ('WT_SESSION' in process.env) {
|
71
|
+
return true;
|
72
|
+
}
|
73
|
+
|
53
74
|
if (process.platform === 'win32') {
|
54
75
|
return false;
|
55
76
|
}
|
56
77
|
|
57
|
-
if (
|
78
|
+
if (CI) {
|
58
79
|
return false;
|
59
80
|
}
|
60
81
|
|
61
|
-
if (
|
82
|
+
if (TEAMCITY_VERSION) {
|
62
83
|
return false;
|
63
84
|
}
|
64
85
|
|
65
|
-
if (
|
66
|
-
const version = parseVersion(
|
86
|
+
if (TERM_PROGRAM) {
|
87
|
+
const version = parseVersion(TERM_PROGRAM_VERSION || '');
|
67
88
|
|
68
|
-
switch (
|
89
|
+
switch (TERM_PROGRAM) {
|
69
90
|
case 'iTerm.app':
|
70
91
|
if (version.major === 3) {
|
71
92
|
return version.minor >= 1;
|
@@ -75,18 +96,19 @@ function supportsHyperlink(stream) {
|
|
75
96
|
case 'WezTerm':
|
76
97
|
return version.major >= 20200620;
|
77
98
|
case 'vscode':
|
99
|
+
// eslint-disable-next-line no-mixed-operators
|
78
100
|
return version.major > 1 || version.major === 1 && version.minor >= 72;
|
79
101
|
// No default
|
80
102
|
}
|
81
103
|
}
|
82
104
|
|
83
|
-
if (
|
105
|
+
if (VTE_VERSION) {
|
84
106
|
// 0.50.0 was supposed to support hyperlinks, but throws a segfault
|
85
|
-
if (
|
107
|
+
if (VTE_VERSION === '0.50.0') {
|
86
108
|
return false;
|
87
109
|
}
|
88
110
|
|
89
|
-
const version = parseVersion(
|
111
|
+
const version = parseVersion(VTE_VERSION);
|
90
112
|
return version.major > 0 || version.minor >= 50;
|
91
113
|
}
|
92
114
|
|
package/license
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
MIT License
|
2
2
|
|
3
|
-
Copyright (c) James Talmage <james@talmage.io> (github.com/jamestalmage)
|
3
|
+
Copyright (c) James Talmage <james@talmage.io> (https://github.com/jamestalmage)
|
4
4
|
|
5
5
|
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:
|
6
6
|
|
package/package.json
CHANGED
@@ -1,48 +1,57 @@
|
|
1
1
|
{
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
2
|
+
"name": "supports-hyperlinks",
|
3
|
+
"version": "3.1.0",
|
4
|
+
"description": "Detect if your terminal emulator supports hyperlinks",
|
5
|
+
"license": "MIT",
|
6
|
+
"repository": "jamestalmage/supports-hyperlinks",
|
7
|
+
"funding": "https://github.com/sponsors/sindresorhus",
|
8
|
+
"author": {
|
9
|
+
"name": "James Talmage",
|
10
|
+
"email": "james@talmage.io",
|
11
|
+
"url": "github.com/jamestalmage"
|
12
|
+
},
|
13
|
+
"exports": {
|
14
|
+
"types": "./index.d.ts",
|
15
|
+
"default": "./index.js"
|
16
|
+
},
|
17
|
+
"sideEffects": false,
|
18
|
+
"engines": {
|
19
|
+
"node": ">=14.18"
|
20
|
+
},
|
21
|
+
"scripts": {
|
22
|
+
"prepublishOnly": "npm run create-types",
|
23
|
+
"test": "xo && nyc ava && tsc",
|
24
|
+
"create-types": "tsc --project declaration.tsconfig.json"
|
25
|
+
},
|
26
|
+
"files": [
|
27
|
+
"index.js",
|
28
|
+
"index.d.ts",
|
29
|
+
"browser.js"
|
30
|
+
],
|
31
|
+
"browser": "browser.js",
|
32
|
+
"keywords": [
|
33
|
+
"link",
|
34
|
+
"terminal",
|
35
|
+
"hyperlink",
|
36
|
+
"cli"
|
37
|
+
],
|
38
|
+
"dependencies": {
|
39
|
+
"has-flag": "^4.0.0",
|
40
|
+
"supports-color": "^7.0.0"
|
41
|
+
},
|
42
|
+
"devDependencies": {
|
43
|
+
"@tsconfig/node14": "^1.0.3",
|
44
|
+
"@types/supports-color": "^8.1.1",
|
45
|
+
"ava": "^2.2.0",
|
46
|
+
"codecov": "^3.5.0",
|
47
|
+
"nyc": "^14.1.1",
|
48
|
+
"typescript": "^4.9.5",
|
49
|
+
"xo": "^0.24.0"
|
50
|
+
},
|
51
|
+
"nyc": {
|
52
|
+
"reporter": [
|
53
|
+
"lcov",
|
54
|
+
"text"
|
55
|
+
]
|
56
|
+
}
|
48
57
|
}
|