supports-hyperlinks 2.3.0 → 3.0.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 +31 -14
- package/package.json +8 -5
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
|
|
@@ -54,18 +70,18 @@ function supportsHyperlink(stream) {
|
|
54
70
|
return false;
|
55
71
|
}
|
56
72
|
|
57
|
-
if (
|
73
|
+
if (CI) {
|
58
74
|
return false;
|
59
75
|
}
|
60
76
|
|
61
|
-
if (
|
77
|
+
if (TEAMCITY_VERSION) {
|
62
78
|
return false;
|
63
79
|
}
|
64
80
|
|
65
|
-
if (
|
66
|
-
const version = parseVersion(
|
81
|
+
if (TERM_PROGRAM) {
|
82
|
+
const version = parseVersion(TERM_PROGRAM_VERSION || '');
|
67
83
|
|
68
|
-
switch (
|
84
|
+
switch (TERM_PROGRAM) {
|
69
85
|
case 'iTerm.app':
|
70
86
|
if (version.major === 3) {
|
71
87
|
return version.minor >= 1;
|
@@ -75,18 +91,19 @@ function supportsHyperlink(stream) {
|
|
75
91
|
case 'WezTerm':
|
76
92
|
return version.major >= 20200620;
|
77
93
|
case 'vscode':
|
94
|
+
// eslint-disable-next-line no-mixed-operators
|
78
95
|
return version.major > 1 || version.major === 1 && version.minor >= 72;
|
79
96
|
// No default
|
80
97
|
}
|
81
98
|
}
|
82
99
|
|
83
|
-
if (
|
100
|
+
if (VTE_VERSION) {
|
84
101
|
// 0.50.0 was supposed to support hyperlinks, but throws a segfault
|
85
|
-
if (
|
102
|
+
if (VTE_VERSION === '0.50.0') {
|
86
103
|
return false;
|
87
104
|
}
|
88
105
|
|
89
|
-
const version = parseVersion(
|
106
|
+
const version = parseVersion(VTE_VERSION);
|
90
107
|
return version.major > 0 || version.minor >= 50;
|
91
108
|
}
|
92
109
|
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "supports-hyperlinks",
|
3
|
-
"version": "
|
3
|
+
"version": "3.0.0",
|
4
4
|
"description": "Detect if your terminal emulator supports hyperlinks",
|
5
5
|
"license": "MIT",
|
6
6
|
"repository": "jamestalmage/supports-hyperlinks",
|
@@ -10,15 +10,16 @@
|
|
10
10
|
"url": "github.com/jamestalmage"
|
11
11
|
},
|
12
12
|
"engines": {
|
13
|
-
"node": ">=
|
13
|
+
"node": ">=14.18"
|
14
14
|
},
|
15
15
|
"scripts": {
|
16
16
|
"prepublishOnly": "npm run create-types",
|
17
|
-
"test": "xo && nyc ava",
|
18
|
-
"create-types": "tsc
|
17
|
+
"test": "xo && nyc ava && tsc",
|
18
|
+
"create-types": "tsc --project declaration.tsconfig.json"
|
19
19
|
},
|
20
20
|
"files": [
|
21
21
|
"index.js",
|
22
|
+
"index.d.ts",
|
22
23
|
"browser.js"
|
23
24
|
],
|
24
25
|
"browser": "browser.js",
|
@@ -33,10 +34,12 @@
|
|
33
34
|
"supports-color": "^7.0.0"
|
34
35
|
},
|
35
36
|
"devDependencies": {
|
37
|
+
"@tsconfig/node14": "^1.0.3",
|
38
|
+
"@types/supports-color": "^8.1.1",
|
36
39
|
"ava": "^2.2.0",
|
37
40
|
"codecov": "^3.5.0",
|
38
41
|
"nyc": "^14.1.1",
|
39
|
-
"typescript": "^
|
42
|
+
"typescript": "^4.9.5",
|
40
43
|
"xo": "^0.24.0"
|
41
44
|
},
|
42
45
|
"nyc": {
|