From a409bf7d190edc38ffc72ef09236c2e85ca77b8d Mon Sep 17 00:00:00 2001 From: tommy-mitchell Date: Wed, 10 Jul 2024 18:31:13 -0500 Subject: [PATCH 1/3] update deps, target Node.js 18 --- .github/workflows/main.yml | 9 +++++---- package.json | 16 ++++++++++------ 2 files changed, 15 insertions(+), 10 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index d36e1a8..a768beb 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -10,11 +10,12 @@ jobs: fail-fast: false matrix: node-version: - - 14 - - 12 + - 21 + - 20 + - 18 steps: - - uses: actions/checkout@v2 - - uses: actions/setup-node@v2 + - uses: actions/checkout@v4 + - uses: actions/setup-node@v4 with: node-version: ${{ matrix.node-version }} - run: npm install diff --git a/package.json b/package.json index ff029fc..6995526 100644 --- a/package.json +++ b/package.json @@ -11,15 +11,19 @@ "url": "https://sindresorhus.com" }, "type": "module", - "exports": "./index.js", + "exports": { + "default": "./index.js", + "types": "./index.d.ts" + }, "engines": { - "node": ">=12" + "node": ">=18" }, "scripts": { - "test": "xo && ava" + "test": "xo && ava && tsd" }, "files": [ - "index.js" + "index.js", + "index.d.ts" ], "keywords": [ "ansi", @@ -48,7 +52,7 @@ "ansi-regex": "^6.0.1" }, "devDependencies": { - "ava": "^3.15.0", - "xo": "^0.44.0" + "ava": "^6.1.3", + "xo": "^0.58.0" } } From cc003c3cd9a598d5028991870f0d8ec6f0eb5e11 Mon Sep 17 00:00:00 2001 From: tommy-mitchell Date: Wed, 10 Jul 2024 18:32:24 -0500 Subject: [PATCH 2/3] add types, type tests --- index.d.ts | 15 +++++++++++++++ index.test-d.ts | 5 +++++ package.json | 1 + 3 files changed, 21 insertions(+) create mode 100644 index.d.ts create mode 100644 index.test-d.ts diff --git a/index.d.ts b/index.d.ts new file mode 100644 index 0000000..2aa0362 --- /dev/null +++ b/index.d.ts @@ -0,0 +1,15 @@ +/** +Check if a string has [ANSI escape codes](https://en.wikipedia.org/wiki/ANSI_escape_code). + +@example +``` +import hasAnsi from 'has-ansi'; + +hasAnsi('\u001B[4mUnicorn\u001B[0m'); +//=> true + +hasAnsi('cake'); +//=> false +``` +*/ +export default function hasAnsi(string: string): boolean; diff --git a/index.test-d.ts b/index.test-d.ts new file mode 100644 index 0000000..cbe25eb --- /dev/null +++ b/index.test-d.ts @@ -0,0 +1,5 @@ +import {expectType} from 'tsd'; +import hasAnsi from './index.js'; + +expectType(hasAnsi('foo\u001B[4mcake\u001B[0m')); +expectType(hasAnsi('cake')); diff --git a/package.json b/package.json index 6995526..d634334 100644 --- a/package.json +++ b/package.json @@ -53,6 +53,7 @@ }, "devDependencies": { "ava": "^6.1.3", + "tsd": "^0.31.1", "xo": "^0.58.0" } } From 1d14052dab9b181cfed8c32d13f1b14623ba5e4b Mon Sep 17 00:00:00 2001 From: tommy-mitchell Date: Wed, 10 Jul 2024 18:33:46 -0500 Subject: [PATCH 3/3] update install command --- readme.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/readme.md b/readme.md index 8bc8460..2e52b53 100644 --- a/readme.md +++ b/readme.md @@ -4,8 +4,8 @@ ## Install -``` -$ npm install has-ansi +```sh +npm install has-ansi ``` ## Usage