diff --git a/.editorconfig b/.editorconfig index 0c7855b..1c6314a 100644 --- a/.editorconfig +++ b/.editorconfig @@ -10,7 +10,3 @@ insert_final_newline = true [*.yml] indent_style = space indent_size = 2 - -[package.json] -indent_style = space -indent_size = 4 diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml new file mode 100644 index 0000000..54a4168 --- /dev/null +++ b/.github/workflows/main.yml @@ -0,0 +1,21 @@ +name: CI +on: + - push + - pull_request +jobs: + test: + name: Node.js ${{ matrix.node-version }} + runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + node-version: + - 22 + - 14 + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-node@v4 + with: + node-version: ${{ matrix.node-version }} + - run: npm install + - run: npm test diff --git a/.github/workflows/node.yml b/.github/workflows/node.yml deleted file mode 100644 index b8625c9..0000000 --- a/.github/workflows/node.yml +++ /dev/null @@ -1,35 +0,0 @@ -name: Node Tests - -on: - push: - branches: - - main - tags: - - '*' - pull_request: - branches: - - main - -permissions: - contents: read - -jobs: - test: - name: Node ${{ matrix.node_version }} on ${{ matrix.os }} - runs-on: ${{ matrix.os }} - strategy: - fail-fast: false - matrix: - node-version: [14,16,18] - os: ['ubuntu-latest'] - - steps: - - uses: actions/checkout@v3 - - - name: Use Node.js ${{ matrix.node-version }} - uses: actions/setup-node@v3 - with: - node-version: ${{ matrix.node-version }} - - - run: npm install - - run: npm test diff --git a/.gitignore b/.gitignore index afec2af..a042fbb 100644 --- a/.gitignore +++ b/.gitignore @@ -2,4 +2,3 @@ node_modules yarn.lock .nyc_output coverage -index.d.ts diff --git a/index.d.ts b/index.d.ts new file mode 100644 index 0000000..30e3172 --- /dev/null +++ b/index.d.ts @@ -0,0 +1,6 @@ +export function supportsHyperlink(stream: { + isTTY?: boolean | undefined; +}): boolean; + +export declare const stdout: boolean; +export declare const stderr: boolean; diff --git a/license b/license index 804ee81..7321378 100644 --- a/license +++ b/license @@ -1,5 +1,6 @@ MIT License +Copyright (c) Sindre Sorhus (https://sindresorhus.com) Copyright (c) James Talmage (https://github.com/jamestalmage) 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: diff --git a/package.json b/package.json index 1832cf2..41e8075 100644 --- a/package.json +++ b/package.json @@ -1,15 +1,10 @@ { "name": "supports-hyperlinks", "version": "3.1.0", - "description": "Detect if your terminal emulator supports hyperlinks", + "description": "Detect whether a terminal supports hyperlinks", "license": "MIT", - "repository": "jamestalmage/supports-hyperlinks", - "funding": "https://github.com/sponsors/sindresorhus", - "author": { - "name": "James Talmage", - "email": "james@talmage.io", - "url": "github.com/jamestalmage" - }, + "repository": "chalk/supports-hyperlinks", + "funding": "https://github.com/chalk/supports-hyperlinks?sponsor=1", "exports": { "types": "./index.d.ts", "default": "./index.js" @@ -19,9 +14,8 @@ "node": ">=14.18" }, "scripts": { - "prepublishOnly": "npm run create-types", - "test": "xo && nyc ava && tsc", - "create-types": "tsc --project declaration.tsconfig.json" + "//test": "xo && ava && tsc", + "test": "ava" }, "files": [ "index.js", @@ -33,7 +27,12 @@ "link", "terminal", "hyperlink", - "cli" + "cli", + "detect", + "check", + "ansi", + "escapes", + "console" ], "dependencies": { "has-flag": "^4.0.0", @@ -42,16 +41,9 @@ "devDependencies": { "@tsconfig/node14": "^1.0.3", "@types/supports-color": "^8.1.1", - "ava": "^2.2.0", + "ava": "^3.2.0", "codecov": "^3.5.0", - "nyc": "^15.1.0", "typescript": "^4.9.5", - "xo": "^0.24.0" - }, - "nyc": { - "reporter": [ - "lcov", - "text" - ] + "xo": "^0.53.0" } } diff --git a/readme.md b/readme.md index 9febc38..08c15e5 100644 --- a/readme.md +++ b/readme.md @@ -1,12 +1,12 @@ -# 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) +# supports-hyperlinks -> Detect whether a terminal emulator supports hyperlinks +> Detect whether a terminal supports hyperlinks 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. This module allows you to detect if hyperlinks are supported in the current Terminal. -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. +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. ## Install @@ -14,11 +14,10 @@ As this is a new development, we anticipate the list of supported Terminals to g npm install supports-hyperlinks ``` - ## Usage ```js -const supportsHyperlinks = require('supports-hyperlinks'); +import supportsHyperlinks from 'supports-hyperlinks'; if (supportsHyperlinks.stdout) { console.log('Terminal stdout supports hyperlinks'); @@ -38,11 +37,3 @@ Returns an `Object` with a `stdout` and `stderr` property for testing either str Obeys the `--no-hyperlinks`, `--hyperlink=always`, and `--hyperlink=never` CLI flags. 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. - -## Related - - * [`hyperlinker`](https://github.com/jamestalmage/hyperlinker): Write hyperlinks for the Terminal. - -## License - -MIT © [James Talmage](https://github.com/jamestalmage) diff --git a/test.js b/test.js index 8d783ea..a37bdd3 100644 --- a/test.js +++ b/test.js @@ -1,5 +1,5 @@ -import test from 'ava'; -import m from '.'; +const test = require('ava'); +const m = require('./index.js'); const isSupported = ({platform, env, argv, stream}) => { platform = platform || 'darwin';