supports-hyperlinks 1.0.1 → 2.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.js +13 -1
- package/package.json +8 -18
- package/readme.md +3 -0
package/index.js
CHANGED
@@ -3,6 +3,16 @@ const supportsColor = require('supports-color');
|
|
3
3
|
const hasFlag = require('has-flag');
|
4
4
|
|
5
5
|
function parseVersion(versionString) {
|
6
|
+
if (/^\d{3,4}$/.test(versionString)) {
|
7
|
+
// Env var doesn't always use dots. example: 4601 => 46.1.0
|
8
|
+
const m = /(\d{1,2})(\d{2})/.exec(versionString);
|
9
|
+
return {
|
10
|
+
major: 0,
|
11
|
+
minor: parseInt(m[1], 10),
|
12
|
+
patch: parseInt(m[2], 10)
|
13
|
+
};
|
14
|
+
}
|
15
|
+
|
6
16
|
const versions = (versionString || '').split('.').map(n => parseInt(n, 10));
|
7
17
|
return {
|
8
18
|
major: versions[0],
|
@@ -12,7 +22,7 @@ function parseVersion(versionString) {
|
|
12
22
|
}
|
13
23
|
|
14
24
|
function supportsHyperlink(stream) {
|
15
|
-
const env = process
|
25
|
+
const {env} = process;
|
16
26
|
|
17
27
|
if ('FORCE_HYPERLINK' in env) {
|
18
28
|
return !(env.FORCE_HYPERLINK.length > 0 && parseInt(env.FORCE_HYPERLINK, 10) === 0);
|
@@ -55,6 +65,7 @@ function supportsHyperlink(stream) {
|
|
55
65
|
if (version.major === 3) {
|
56
66
|
return version.minor >= 1;
|
57
67
|
}
|
68
|
+
|
58
69
|
return version.major > 3;
|
59
70
|
// No default
|
60
71
|
}
|
@@ -65,6 +76,7 @@ function supportsHyperlink(stream) {
|
|
65
76
|
if (env.VTE_VERSION === '0.50.0') {
|
66
77
|
return false;
|
67
78
|
}
|
79
|
+
|
68
80
|
const version = parseVersion(env.VTE_VERSION);
|
69
81
|
return version.major > 0 || version.minor >= 50;
|
70
82
|
}
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "supports-hyperlinks",
|
3
|
-
"version": "
|
3
|
+
"version": "2.0.0",
|
4
4
|
"description": "Detect if your terminal emulator supports hyperlinks",
|
5
5
|
"license": "MIT",
|
6
6
|
"repository": "jamestalmage/supports-hyperlinks",
|
@@ -10,7 +10,7 @@
|
|
10
10
|
"url": "github.com/jamestalmage"
|
11
11
|
},
|
12
12
|
"engines": {
|
13
|
-
"node": ">=
|
13
|
+
"node": ">=8"
|
14
14
|
},
|
15
15
|
"scripts": {
|
16
16
|
"test": "xo && nyc ava"
|
@@ -27,24 +27,14 @@
|
|
27
27
|
"cli"
|
28
28
|
],
|
29
29
|
"dependencies": {
|
30
|
-
"has-flag": "^
|
31
|
-
"supports-color": "^
|
30
|
+
"has-flag": "^4.0.0",
|
31
|
+
"supports-color": "^7.0.0"
|
32
32
|
},
|
33
33
|
"devDependencies": {
|
34
|
-
"ava": "^
|
35
|
-
"
|
36
|
-
"
|
37
|
-
"
|
38
|
-
"nyc": "^11.0.0",
|
39
|
-
"xo": "^0.18.2"
|
40
|
-
},
|
41
|
-
"ava": {
|
42
|
-
"babel": {
|
43
|
-
"presets": [
|
44
|
-
"env",
|
45
|
-
"stage-3"
|
46
|
-
]
|
47
|
-
}
|
34
|
+
"ava": "^2.2.0",
|
35
|
+
"codecov": "^3.5.0",
|
36
|
+
"nyc": "^14.1.1",
|
37
|
+
"xo": "^0.24.0"
|
48
38
|
},
|
49
39
|
"nyc": {
|
50
40
|
"reporter": [
|
package/readme.md
CHANGED
@@ -39,6 +39,9 @@ Obeys the `--no-hyperlinks`, `--hyperlink=always`, and `--hyperlink=never` CLI f
|
|
39
39
|
|
40
40
|
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.
|
41
41
|
|
42
|
+
## Related
|
43
|
+
|
44
|
+
* [`hyperlinker`](https://github.com/jamestalmage/hyperlinker): Write hyperlinks for the Terminal.
|
42
45
|
|
43
46
|
## License
|
44
47
|
|