supports-hyperlinks 3.0.0 → 3.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.
package/index.d.ts CHANGED
@@ -1,5 +1,6 @@
1
1
  export function supportsHyperlink(stream: {
2
2
  isTTY?: boolean | undefined;
3
3
  }): boolean;
4
+
4
5
  export declare const stdout: boolean;
5
6
  export declare const stderr: boolean;
package/index.js CHANGED
@@ -29,6 +29,7 @@ function parseVersion(versionString) {
29
29
  @param {{ isTTY?: boolean | undefined }} stream
30
30
  @returns {boolean}
31
31
  */
32
+ // eslint-disable-next-line complexity
32
33
  function supportsHyperlink(stream) {
33
34
  const {
34
35
  CI,
@@ -37,7 +38,8 @@ function supportsHyperlink(stream) {
37
38
  TEAMCITY_VERSION,
38
39
  TERM_PROGRAM,
39
40
  TERM_PROGRAM_VERSION,
40
- VTE_VERSION
41
+ VTE_VERSION,
42
+ TERM,
41
43
  } = process.env;
42
44
 
43
45
  if (FORCE_HYPERLINK) {
@@ -66,6 +68,11 @@ function supportsHyperlink(stream) {
66
68
  return false;
67
69
  }
68
70
 
71
+ // Windows Terminal
72
+ if ('WT_SESSION' in process.env) {
73
+ return true;
74
+ }
75
+
69
76
  if (process.platform === 'win32') {
70
77
  return false;
71
78
  }
@@ -93,6 +100,8 @@ function supportsHyperlink(stream) {
93
100
  case 'vscode':
94
101
  // eslint-disable-next-line no-mixed-operators
95
102
  return version.major > 1 || version.major === 1 && version.minor >= 72;
103
+ case 'ghostty':
104
+ return true;
96
105
  // No default
97
106
  }
98
107
  }
@@ -107,6 +116,13 @@ function supportsHyperlink(stream) {
107
116
  return version.major > 0 || version.minor >= 50;
108
117
  }
109
118
 
119
+ switch (TERM) {
120
+ case 'alacritty':
121
+ // Support added in v0.11 (2022-10-13)
122
+ return true;
123
+ // No default
124
+ }
125
+
110
126
  return false;
111
127
  }
112
128
 
package/license CHANGED
@@ -1,6 +1,7 @@
1
1
  MIT License
2
2
 
3
- Copyright (c) James Talmage <james@talmage.io> (github.com/jamestalmage)
3
+ Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (https://sindresorhus.com)
4
+ Copyright (c) James Talmage <james@talmage.io> (https://github.com/jamestalmage)
4
5
 
5
6
  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
7
 
package/package.json CHANGED
@@ -1,51 +1,49 @@
1
1
  {
2
- "name": "supports-hyperlinks",
3
- "version": "3.0.0",
4
- "description": "Detect if your terminal emulator supports hyperlinks",
5
- "license": "MIT",
6
- "repository": "jamestalmage/supports-hyperlinks",
7
- "author": {
8
- "name": "James Talmage",
9
- "email": "james@talmage.io",
10
- "url": "github.com/jamestalmage"
11
- },
12
- "engines": {
13
- "node": ">=14.18"
14
- },
15
- "scripts": {
16
- "prepublishOnly": "npm run create-types",
17
- "test": "xo && nyc ava && tsc",
18
- "create-types": "tsc --project declaration.tsconfig.json"
19
- },
20
- "files": [
21
- "index.js",
22
- "index.d.ts",
23
- "browser.js"
24
- ],
25
- "browser": "browser.js",
26
- "keywords": [
27
- "link",
28
- "terminal",
29
- "hyperlink",
30
- "cli"
31
- ],
32
- "dependencies": {
33
- "has-flag": "^4.0.0",
34
- "supports-color": "^7.0.0"
35
- },
36
- "devDependencies": {
37
- "@tsconfig/node14": "^1.0.3",
38
- "@types/supports-color": "^8.1.1",
39
- "ava": "^2.2.0",
40
- "codecov": "^3.5.0",
41
- "nyc": "^14.1.1",
42
- "typescript": "^4.9.5",
43
- "xo": "^0.24.0"
44
- },
45
- "nyc": {
46
- "reporter": [
47
- "lcov",
48
- "text"
49
- ]
50
- }
2
+ "name": "supports-hyperlinks",
3
+ "version": "3.2.0",
4
+ "description": "Detect whether a terminal supports hyperlinks",
5
+ "license": "MIT",
6
+ "repository": "chalk/supports-hyperlinks",
7
+ "funding": "https://github.com/chalk/supports-hyperlinks?sponsor=1",
8
+ "exports": {
9
+ "types": "./index.d.ts",
10
+ "default": "./index.js"
11
+ },
12
+ "sideEffects": false,
13
+ "engines": {
14
+ "node": ">=14.18"
15
+ },
16
+ "scripts": {
17
+ "//test": "xo && ava && tsc",
18
+ "test": "ava"
19
+ },
20
+ "files": [
21
+ "index.js",
22
+ "index.d.ts",
23
+ "browser.js"
24
+ ],
25
+ "browser": "browser.js",
26
+ "keywords": [
27
+ "link",
28
+ "terminal",
29
+ "hyperlink",
30
+ "cli",
31
+ "detect",
32
+ "check",
33
+ "ansi",
34
+ "escapes",
35
+ "console"
36
+ ],
37
+ "dependencies": {
38
+ "has-flag": "^4.0.0",
39
+ "supports-color": "^7.0.0"
40
+ },
41
+ "devDependencies": {
42
+ "@tsconfig/node14": "^1.0.3",
43
+ "@types/supports-color": "^8.1.1",
44
+ "ava": "^3.2.0",
45
+ "codecov": "^3.5.0",
46
+ "typescript": "^4.9.5",
47
+ "xo": "^0.53.0"
48
+ }
51
49
  }
package/readme.md CHANGED
@@ -1,24 +1,23 @@
1
- # 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)
1
+ # supports-hyperlinks
2
2
 
3
- > Detect whether a terminal emulator supports hyperlinks
3
+ > Detect whether a terminal supports hyperlinks
4
4
 
5
5
  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.
6
6
 
7
7
  This module allows you to detect if hyperlinks are supported in the current Terminal.
8
8
 
9
- 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.
9
+ 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.
10
10
 
11
11
  ## Install
12
12
 
13
+ ```sh
14
+ npm install supports-hyperlinks
13
15
  ```
14
- $ npm install supports-hyperlinks
15
- ```
16
-
17
16
 
18
17
  ## Usage
19
18
 
20
19
  ```js
21
- const supportsHyperlinks = require('supports-hyperlinks');
20
+ import supportsHyperlinks from 'supports-hyperlinks';
22
21
 
23
22
  if (supportsHyperlinks.stdout) {
24
23
  console.log('Terminal stdout supports hyperlinks');
@@ -38,11 +37,3 @@ Returns an `Object` with a `stdout` and `stderr` property for testing either str
38
37
  Obeys the `--no-hyperlinks`, `--hyperlink=always`, and `--hyperlink=never` CLI flags.
39
38
 
40
39
  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
-
42
- ## Related
43
-
44
- * [`hyperlinker`](https://github.com/jamestalmage/hyperlinker): Write hyperlinks for the Terminal.
45
-
46
- ## License
47
-
48
- MIT © [James Talmage](https://github.com/jamestalmage)