From 7a6893551d93ebe0bd031141b3e2b91d7e0676aa Mon Sep 17 00:00:00 2001 From: Sindre Sorhus Date: Fri, 26 Nov 2021 16:50:15 +0700 Subject: [PATCH] Fix code coverage --- .github/workflows/main.yml | 5 +++++ package.json | 21 ++++++++++++++------- readme.md | 5 ++++- source/utilities.js | 1 + 4 files changed, 24 insertions(+), 8 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index d36e1a8..ef5d807 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -10,6 +10,7 @@ jobs: fail-fast: false matrix: node-version: + - 16 - 14 - 12 steps: @@ -19,3 +20,7 @@ jobs: node-version: ${{ matrix.node-version }} - run: npm install - run: npm test + - uses: codecov/codecov-action@v2 + if: matrix.node-version == 16 + with: + fail_ci_if_error: true diff --git a/package.json b/package.json index a9b7d79..fd72b27 100644 --- a/package.json +++ b/package.json @@ -14,11 +14,12 @@ "default": "./source/vendor/supports-color/browser.js" } }, + "types": "./source/index.d.ts", "engines": { "node": "^12.17.0 || ^14.13 || >=16.0.0" }, "scripts": { - "test": "xo && nyc ava && tsd", + "test": "xo && c8 ava && tsd", "bench": "matcha benchmark.js" }, "files": [ @@ -48,23 +49,29 @@ "text" ], "devDependencies": { + "@types/node": "^16.11.10", "ava": "^3.15.0", + "c8": "^7.10.0", "color-convert": "^2.0.1", - "coveralls": "^3.1.1", "execa": "^6.0.0", "log-update": "^5.0.0", "matcha": "^0.7.0", - "nyc": "^15.1.0", "tsd": "^0.19.0", - "typescript": "^4.5.2", "xo": "^0.47.0", "yoctodelay": "^2.0.0" }, - "types": "./source/index.d.ts", "xo": { "rules": { - "unicorn/prefer-string-slice": "off", - "unicorn/better-regex": "off" + "unicorn/prefer-string-slice": "off" } + }, + "c8": { + "reporter": [ + "text", + "lcov" + ], + "exclude": [ + "source/vendor" + ] } } diff --git a/readme.md b/readme.md index ed157bd..f6adc80 100644 --- a/readme.md +++ b/readme.md @@ -9,7 +9,7 @@ > Terminal string styling done right -[![Coverage Status](https://coveralls.io/repos/github/chalk/chalk/badge.svg?branch=main)](https://coveralls.io/github/chalk/chalk?branch=main) +[![Coverage Status](https://codecov.io/gh/chalk/chalk/branch/main/graph/badge.svg)](https://codecov.io/gh/chalk/chalk) [![npm dependents](https://badgen.net/npm/dependents/chalk)](https://www.npmjs.com/package/chalk?activeTab=dependents) [![Downloads](https://badgen.net/npm/dt/chalk)](https://www.npmjs.com/package/chalk) [![run on repl.it](https://repl.it/badge/github/chalk/chalk)](https://repl.it/github/chalk/chalk) [![Support Chalk on DEV](https://badge.devprotocol.xyz/0x44d871aebF0126Bf646753E2C976Aa7e68A66c15/descriptive)](https://stakes.social/0x44d871aebF0126Bf646753E2C976Aa7e68A66c15) @@ -72,6 +72,7 @@ - Expressive API - Highly performant +- No dependencies - Ability to nest styles - [256/Truecolor color support](#256-and-truecolor-color-support) - Auto-detects color support @@ -86,6 +87,8 @@ npm install chalk ``` +**IMPORTANT:** Chalk 5 is ESM. If you want to use Chalk with TypeScript or a build tool, you will probably want to use Chalk 4 for now. [Read more.](https://github.com/chalk/chalk/releases/tag/v5.0.0) + ## Usage ```js diff --git a/source/utilities.js b/source/utilities.js index 4d8bc4a..5d49dad 100644 --- a/source/utilities.js +++ b/source/utilities.js @@ -1,3 +1,4 @@ +// TODO: When targeting Node.js 16, use `String.prototype.replaceAll`. export function stringReplaceAll(string, substring, replacer) { let index = string.indexOf(substring); if (index === -1) {