diff --git a/.github/workflows/bench.yml b/.github/workflows/bench.yml new file mode 100644 index 0000000..fb0845e --- /dev/null +++ b/.github/workflows/bench.yml @@ -0,0 +1,12 @@ +name: Benchmarks +on: [push, pull_request] +jobs: + bench: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - uses: actions/setup-node@v2 + with: + node-version: 16 + - name: Benchmarks + run: FORCE_COLOR= npm --prefix bench start diff --git a/.github/workflows/test.cjs.yml b/.github/workflows/test.cjs.yml new file mode 100644 index 0000000..066dad9 --- /dev/null +++ b/.github/workflows/test.cjs.yml @@ -0,0 +1,22 @@ +name: Legacy Node Tests +on: [push, pull_request] +jobs: + test: + env: + NODE_ENV: development + runs-on: ubuntu-latest + strategy: + matrix: + node-version: [10.x] + steps: + - name: Checkout + uses: actions/checkout@v1 + - name: Use Node.js ${{ matrix.node-version }} + uses: actions/setup-node@v1 + with: + node-version: ${{ matrix.node-version }} + - name: Test + run: | + npm install && npm install tape + FORCE_COLOR= npx tape tests/index.test.cjs + diff --git a/.github/workflows/ci.yml b/.github/workflows/test.yml similarity index 79% rename from .github/workflows/ci.yml rename to .github/workflows/test.yml index e4582a0..b134bca 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/test.yml @@ -1,5 +1,5 @@ -name: CI -on: push +name: Tests +on: [push, pull_request] jobs: test: env: @@ -17,7 +17,6 @@ jobs: node-version: ${{ matrix.node-version }} - name: Test run: | - npm install -g codecov npm install - FORCE_COLOR= npm test - codecov \ No newline at end of file + FORCE_COLOR= npx c8 --reporter=lcov npm test && npx codecov + diff --git a/README.md b/README.md index 53badae..693ae44 100644 --- a/README.md +++ b/README.md @@ -1,13 +1,17 @@ -# Colorette +# 🌈Colorette -> Easily set the text color and style in the terminal. +> Easily set your terminal text color & styles. -- No wonky prototype method-chain API. -- Automatic color support detection. -- Up to [2x faster](#benchmarks) than alternatives. -- [`NO_COLOR`](https://no-color.org) friendly. 👌 +- No dependecies +- Automatic color support detection +- Up to [2x faster](#benchmarks) than alternatives +- TypeScript support +- [`NO_COLOR`](https://no-color.org) friendly +- Node >= `10` -Here's the first example to get you started. +> [**Upgrading from Colorette `1.x`?**](https://github.com/jorgebucaran/colorette/issues/70) + +## Quickstart ```js import { blue, bold, underline } from "colorette" @@ -30,16 +34,20 @@ console.log(` `) ``` -Of course, you can nest styles without breaking existing color sequences. +You can also nest styles without breaking existing color sequences. ```js console.log(bold(`I'm ${blue(`da ba ${underline("dee")} da ba`)} daa`)) ``` -Feeling adventurous? Try the [pipeline operator](https://github.com/tc39/proposal-pipeline-operator). +Need to override terminal color detection? You can do that too. ```js -console.log("Da ba dee da ba daa" |> blue |> bold) +import { createColors } from "colorette" + +const { blue } = createColors({ useColor: false }) + +console.log(blue("Blue? Nope, nah")) ``` ## Installation @@ -50,9 +58,9 @@ npm install colorette ## API -### `