supports-hyperlinks 1.0.0 → 2.2.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.
Files changed (3) hide show
  1. package/index.js +17 -1
  2. package/package.json +16 -20
  3. 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.env;
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);
@@ -39,6 +49,10 @@ function supportsHyperlink(stream) {
39
49
  return false;
40
50
  }
41
51
 
52
+ if ('NETLIFY' in env) {
53
+ return true;
54
+ }
55
+
42
56
  if ('CI' in env) {
43
57
  return false;
44
58
  }
@@ -55,6 +69,7 @@ function supportsHyperlink(stream) {
55
69
  if (version.major === 3) {
56
70
  return version.minor >= 1;
57
71
  }
72
+
58
73
  return version.major > 3;
59
74
  // No default
60
75
  }
@@ -65,6 +80,7 @@ function supportsHyperlink(stream) {
65
80
  if (env.VTE_VERSION === '0.50.0') {
66
81
  return false;
67
82
  }
83
+
68
84
  const version = parseVersion(env.VTE_VERSION);
69
85
  return version.major > 0 || version.minor >= 50;
70
86
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "supports-hyperlinks",
3
- "version": "1.0.0",
3
+ "version": "2.2.0",
4
4
  "description": "Detect if your terminal emulator supports hyperlinks",
5
5
  "license": "MIT",
6
6
  "repository": "jamestalmage/supports-hyperlinks",
@@ -10,10 +10,12 @@
10
10
  "url": "github.com/jamestalmage"
11
11
  },
12
12
  "engines": {
13
- "node": ">=4"
13
+ "node": ">=8"
14
14
  },
15
15
  "scripts": {
16
- "test": "xo && nyc ava"
16
+ "prepublishOnly": "npm run create-types",
17
+ "test": "xo && nyc ava",
18
+ "create-types": "tsc index.js --allowJs --declaration --emitDeclarationOnly"
17
19
  },
18
20
  "files": [
19
21
  "index.js",
@@ -21,27 +23,21 @@
21
23
  ],
22
24
  "browser": "browser.js",
23
25
  "keywords": [
24
- ""
26
+ "link",
27
+ "terminal",
28
+ "hyperlink",
29
+ "cli"
25
30
  ],
26
31
  "dependencies": {
27
- "has-flag": "^2.0.0",
28
- "supports-color": "^5.0.0"
32
+ "has-flag": "^4.0.0",
33
+ "supports-color": "^7.0.0"
29
34
  },
30
35
  "devDependencies": {
31
- "ava": "^0.20.0",
32
- "babel-preset-env": "^1.6.1",
33
- "babel-preset-stage-3": "^6.24.1",
34
- "codecov": "^2.2.0",
35
- "nyc": "^11.0.0",
36
- "xo": "^0.18.2"
37
- },
38
- "ava": {
39
- "babel": {
40
- "presets": [
41
- "env",
42
- "stage-3"
43
- ]
44
- }
36
+ "ava": "^2.2.0",
37
+ "codecov": "^3.5.0",
38
+ "nyc": "^14.1.1",
39
+ "typescript": "^3.7.2",
40
+ "xo": "^0.24.0"
45
41
  },
46
42
  "nyc": {
47
43
  "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