pax_global_header00006660000000000000000000000064141276275560014531gustar00rootroot0000000000000052 comment=3deaf7866046cfc962bdd43bdffe76b21dd7c12b colorette-2.0.16/000077500000000000000000000000001412762755600136175ustar00rootroot00000000000000colorette-2.0.16/.github/000077500000000000000000000000001412762755600151575ustar00rootroot00000000000000colorette-2.0.16/.github/workflows/000077500000000000000000000000001412762755600172145ustar00rootroot00000000000000colorette-2.0.16/.github/workflows/bench.yml000066400000000000000000000004321412762755600210150ustar00rootroot00000000000000name: 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 colorette-2.0.16/.github/workflows/test.cjs.yml000066400000000000000000000010301412762755600214660ustar00rootroot00000000000000name: 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 colorette-2.0.16/.github/workflows/test.yml000066400000000000000000000010171412762755600207150ustar00rootroot00000000000000name: Tests on: [push, pull_request] jobs: test: env: NODE_ENV: development runs-on: ubuntu-latest strategy: matrix: node-version: [12.x, 14.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 FORCE_COLOR= npx c8 --reporter=lcov npm test && npx codecov colorette-2.0.16/.gitignore000066400000000000000000000001011412762755600155770ustar00rootroot00000000000000*.br *.gz *.cjs package-lock.json node_modules coverage /.idea/ colorette-2.0.16/LICENSE.md000066400000000000000000000020701412762755600152220ustar00rootroot00000000000000Copyright © Jorge Bucaran <> 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: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. colorette-2.0.16/README.md000066400000000000000000000101511412762755600150740ustar00rootroot00000000000000# 🌈Colorette > Easily set your terminal text color & styles. - No dependecies - Automatic color support detection - Up to [2x faster](#benchmarks) than alternatives - TypeScript support - [`NO_COLOR`](https://no-color.org) friendly - Node >= `10` > [**Upgrading from Colorette `1.x`?**](https://github.com/jorgebucaran/colorette/issues/70) ## Quickstart ```js import { blue, bold, underline } from "colorette" console.log( blue("I'm blue"), bold(blue("da ba dee")), underline(bold(blue("da ba daa"))) ) ``` Here's an example using [template literals](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Template_literals). ```js console.log(` There's a ${underline(blue("house"))}, With a ${bold(blue("window"))}, And a ${blue("corvette")} And everything is blue `) ``` You can also nest styles without breaking existing color sequences. ```js console.log(bold(`I'm ${blue(`da ba ${underline("dee")} da ba`)} daa`)) ``` Need to override terminal color detection? You can do that too. ```js import { createColors } from "colorette" const { blue } = createColors({ useColor: false }) console.log(blue("Blue? Nope, nah")) ``` ## Installation ```console npm install colorette ``` ## API ### \() > See all [supported colors](#supported-colors). ```js import { blue } from "colorette" blue("I'm blue") //=> \x1b[34mI'm blue\x1b[39m ``` ### createColors() Override terminal color detection via `createColors({ useColor })`. ```js import { createColors } from "colorette" const { blue } = createColors({ useColor: false }) ``` ### isColorSupported `true` if your terminal supports color, `false` otherwise. Used internally, but exposed for convenience. ## Environment You can override color detection from the CLI by setting the `--no-color` or `--color` flags. ```console $ ./example.js --no-color | ./consumer.js ``` Or if you can't use CLI flags, by setting the `NO_COLOR=` or `FORCE_COLOR=` environment variables. ```console $ NO_COLOR= ./example.js | ./consumer.js ``` ## Supported colors | Colors | Background Colors | Bright Colors | Bright Background Colors | Modifiers | | ------- | ----------------- | ------------- | ------------------------ | ----------------- | | black | bgBlack | blackBright | bgBlackBright | dim | | red | bgRed | redBright | bgRedBright | **bold** | | green | bgGreen | greenBright | bgGreenBright | hidden | | yellow | bgYellow | yellowBright | bgYellowBright | _italic_ | | blue | bgBlue | blueBright | bgBlueBright | underline | | magenta | bgMagenta | magentaBright | bgMagentaBright | ~~strikethrough~~ | | cyan | bgCyan | cyanBright | bgCyanBright | reset | | white | bgWhite | whiteBright | bgWhiteBright | | | gray | | | | | ## [Benchmarks](https://github.com/jorgebucaran/colorette/actions/workflows/bench.yml) ```console npm --prefix bench start ``` ```diff chalk 1,786,703 ops/sec kleur 1,618,960 ops/sec colors 646,823 ops/sec ansi-colors 786,149 ops/sec picocolors 2,871,758 ops/sec + colorette 3,002,751 ops/sec ``` ## Acknowledgements Colorette started out in 2015 by [@jorgebucaran](https://github.com/jorgebucaran) as a lightweight alternative to [Chalk](https://github.com/chalk/chalk) and was introduced originally as [Clor](https://github.com/jorgebucaran/colorette/commit/b01b5b9961ceb7df878583a3002e836fae9e37ce). Our terminal color detection logic borrows heavily from [@sindresorhus](https://github.com/sindresorhus) and [@Qix-](https://github.com/Qix-) work on Chalk. The idea of slicing strings to clear bleeding sequences was adapted from a similar technique used by [@alexeyraspopov](https://github.com/alexeyraspopov) in [picocolors](https://github.com/alexeyraspopov/picocolors). Thank you to all our contributors! <3 ## License [MIT](LICENSE.md) colorette-2.0.16/bench/000077500000000000000000000000001412762755600146765ustar00rootroot00000000000000colorette-2.0.16/bench/index.js000066400000000000000000000013551412762755600163470ustar00rootroot00000000000000import * as colorette from "../index.js" import bench from "benchmark" import chalk from "chalk" import kleur from "kleur" import colors from "colors" import picocolors from "picocolors" import ansicolors from "ansi-colors" const test = (c) => c.red(`${c.bold(`${c.cyan(`${c.yellow("yellow")}cyan`)}`)}red`) new bench.Suite() .add(" chalk ", () => test(chalk)) .add(" kleur ", () => test(kleur)) .add(" colors ", () => test(colors)) .add(" ansi-colors ", () => test(ansicolors)) .add(" picocolors ", () => test(picocolors)) .add("+ colorette ", () => test(colorette)) .on("cycle", ({ target: { name, hz } }) => console.log(name, `${Math.floor(hz).toLocaleString()} ops/sec`.padStart(18)) ) .run() colorette-2.0.16/bench/package.json000066400000000000000000000004011412762755600171570ustar00rootroot00000000000000{ "private": true, "type": "module", "scripts": { "start": "npm install && node index.js" }, "devDependencies": { "ansi-colors": "*", "picocolors": "*", "benchmark": "*", "chalk": "*", "colors": "*", "kleur": "*" } } colorette-2.0.16/index.d.ts000066400000000000000000000037741412762755600155330ustar00rootroot00000000000000declare module "colorette" { type Color = (text: string | number) => string interface Colorette { reset: Color bold: Color dim: Color italic: Color underline: Color inverse: Color hidden: Color strikethrough: Color black: Color red: Color green: Color yellow: Color blue: Color magenta: Color cyan: Color white: Color gray: Color bgBlack: Color bgRed: Color bgGreen: Color bgYellow: Color bgBlue: Color bgMagenta: Color bgCyan: Color bgWhite: Color blackBright: Color redBright: Color greenBright: Color yellowBright: Color blueBright: Color magentaBright: Color cyanBright: Color whiteBright: Color bgBlackBright: Color bgRedBright: Color bgGreenBright: Color bgYellowBright: Color bgBlueBright: Color bgMagentaBright: Color bgCyanBright: Color bgWhiteBright: Color } const reset: Color const bold: Color const dim: Color const italic: Color const underline: Color const inverse: Color const hidden: Color const strikethrough: Color const black: Color const red: Color const green: Color const yellow: Color const blue: Color const magenta: Color const cyan: Color const white: Color const gray: Color const bgBlack: Color const bgRed: Color const bgGreen: Color const bgYellow: Color const bgBlue: Color const bgMagenta: Color const bgCyan: Color const bgWhite: Color const blackBright: Color const redBright: Color const greenBright: Color const yellowBright: Color const blueBright: Color const magentaBright: Color const cyanBright: Color const whiteBright: Color const bgBlackBright: Color const bgRedBright: Color const bgGreenBright: Color const bgYellowBright: Color const bgBlueBright: Color const bgMagentaBright: Color const bgCyanBright: Color const bgWhiteBright: Color const isColorSupported: boolean function createColors(options?: { useColor: boolean }): Colorette } colorette-2.0.16/index.js000066400000000000000000000063621412762755600152730ustar00rootroot00000000000000import * as tty from "tty" const env = process.env || {} const argv = process.argv || [] const isDisabled = "NO_COLOR" in env || argv.includes("--no-color") const isForced = "FORCE_COLOR" in env || argv.includes("--color") const isWindows = process.platform === "win32" const isCompatibleTerminal = tty && tty.isatty && tty.isatty(1) && env.TERM && env.TERM !== "dumb" const isCI = "CI" in env && ("GITHUB_ACTIONS" in env || "GITLAB_CI" in env || "CIRCLECI" in env) export const isColorSupported = !isDisabled && (isForced || isWindows || isCompatibleTerminal || isCI) const replaceClose = ( index, string, close, replace, head = string.substring(0, index) + replace, tail = string.substring(index + close.length), next = tail.indexOf(close) ) => head + (next < 0 ? tail : replaceClose(next, tail, close, replace)) const clearBleed = (index, string, open, close, replace) => index < 0 ? open + string + close : open + replaceClose(index, string, close, replace) + close const filterEmpty = (open, close, replace = open, at = open.length + 1) => (string) => string || !(string === "" || string === undefined) ? clearBleed( ("" + string).indexOf(close, at), string, open, close, replace ) : "" const init = (open, close, replace) => filterEmpty(`\x1b[${open}m`, `\x1b[${close}m`, replace) const colors = { reset: init(0, 0), bold: init(1, 22, "\x1b[22m\x1b[1m"), dim: init(2, 22, "\x1b[22m\x1b[2m"), italic: init(3, 23), underline: init(4, 24), inverse: init(7, 27), hidden: init(8, 28), strikethrough: init(9, 29), black: init(30, 39), red: init(31, 39), green: init(32, 39), yellow: init(33, 39), blue: init(34, 39), magenta: init(35, 39), cyan: init(36, 39), white: init(37, 39), gray: init(90, 39), bgBlack: init(40, 49), bgRed: init(41, 49), bgGreen: init(42, 49), bgYellow: init(43, 49), bgBlue: init(44, 49), bgMagenta: init(45, 49), bgCyan: init(46, 49), bgWhite: init(47, 49), blackBright: init(90, 39), redBright: init(91, 39), greenBright: init(92, 39), yellowBright: init(93, 39), blueBright: init(94, 39), magentaBright: init(95, 39), cyanBright: init(96, 39), whiteBright: init(97, 39), bgBlackBright: init(100, 49), bgRedBright: init(101, 49), bgGreenBright: init(102, 49), bgYellowBright: init(103, 49), bgBlueBright: init(104, 49), bgMagentaBright: init(105, 49), bgCyanBright: init(106, 49), bgWhiteBright: init(107, 49), } const none = (any) => any export const createColors = ({ useColor = isColorSupported } = {}) => useColor ? colors : Object.keys(colors).reduce( (colors, key) => ({ ...colors, [key]: none }), {} ) export const { reset, bold, dim, italic, underline, inverse, hidden, strikethrough, black, red, green, yellow, blue, magenta, cyan, white, gray, bgBlack, bgRed, bgGreen, bgYellow, bgBlue, bgMagenta, bgCyan, bgWhite, blackBright, redBright, greenBright, yellowBright, blueBright, magentaBright, cyanBright, whiteBright, bgBlackBright, bgRedBright, bgGreenBright, bgYellowBright, bgBlueBright, bgMagentaBright, bgCyanBright, bgWhiteBright, } = createColors() colorette-2.0.16/package.json000066400000000000000000000017371412762755600161150ustar00rootroot00000000000000{ "name": "colorette", "version": "2.0.16", "type": "module", "main": "index.cjs", "module": "index.js", "types": "index.d.ts", "description": "🌈Easily set your terminal text color & styles.", "repository": "jorgebucaran/colorette", "license": "MIT", "exports": { "./package.json": "./package.json", ".": { "require": "./index.cjs", "import": "./index.js" } }, "files": [ "*.*(c)[tj]s*" ], "author": "Jorge Bucaran", "keywords": [ "terminal", "styles", "color", "ansi" ], "scripts": { "test": "c8 twist tests/*.js", "build": "npx rollup --format cjs --input index.js --file index.cjs", "deploy": "npm test && git commit --all --message $tag && git tag --sign $tag --message $tag && git push && git push --tags", "release": "tag=$npm_package_version npm run deploy && npm publish --access public", "prepare": "npm run build" }, "devDependencies": { "c8": "*", "twist": "*" } } colorette-2.0.16/tests/000077500000000000000000000000001412762755600147615ustar00rootroot00000000000000colorette-2.0.16/tests/createColors.test.js000066400000000000000000000010371412762755600207230ustar00rootroot00000000000000import { blue, createColors } from "../index.js" import { t, equal } from "twist" export default [ t("colorette", [ t("createColors", [ t("useColor overrides automatic color detection", [ (done) => { done([ equal( blue("megazord"), createColors({ useColor: true }).blue("megazord") ), equal( "megazord", createColors({ useColor: false }).blue("megazord") ), ]) }, ]), ]), ]), ] colorette-2.0.16/tests/environment.test.js000066400000000000000000000014741412762755600206470ustar00rootroot00000000000000import { exec } from "child_process" import { fileURLToPath } from "url" import { dirname } from "path" import { t, equal } from "twist" const SCRIPTS_PATH = `${dirname(fileURLToPath(import.meta.url))}/scripts` const exitStatusSuccess = (done) => (error) => done(equal(error, null)) const sh = (file, assert) => (done) => exec(`sh ${file}`, assert(done)) export default [ t("variables", [ t("`FORCE_COLOR` forces color", [ sh(`${SCRIPTS_PATH}/FORCE_COLOR.sh`, exitStatusSuccess), ]), t("`NO_COLOR` disables color", [ sh(`${SCRIPTS_PATH}/NO_COLOR.sh`, exitStatusSuccess), ]), t("`--no-color` disables color", [ sh(`${SCRIPTS_PATH}/--no-color.sh`, exitStatusSuccess), ]), t("`--color` enables color", [ sh(`${SCRIPTS_PATH}/--color.sh`, exitStatusSuccess), ]), ]), ] colorette-2.0.16/tests/index.test.cjs000066400000000000000000000101611412762755600175460ustar00rootroot00000000000000const c = require("../") const test = require("tape") const exec = require("child_process").exec const colors = [ ["reset", "\x1b[0m", "\x1b[0m"], ["bold", "\x1b[1m", "\x1b[22m"], ["dim", "\x1b[2m", "\x1b[22m"], ["italic", "\x1b[3m", "\x1b[23m"], ["underline", "\x1b[4m", "\x1b[24m"], ["inverse", "\x1b[7m", "\x1b[27m"], ["hidden", "\x1b[8m", "\x1b[28m"], ["strikethrough", "\x1b[9m", "\x1b[29m"], ["black", "\x1b[30m", "\x1b[39m"], ["red", "\x1b[31m", "\x1b[39m"], ["green", "\x1b[32m", "\x1b[39m"], ["yellow", "\x1b[33m", "\x1b[39m"], ["blue", "\x1b[34m", "\x1b[39m"], ["magenta", "\x1b[35m", "\x1b[39m"], ["cyan", "\x1b[36m", "\x1b[39m"], ["white", "\x1b[37m", "\x1b[39m"], ["gray", "\x1b[90m", "\x1b[39m"], ["bgBlack", "\x1b[40m", "\x1b[49m"], ["bgRed", "\x1b[41m", "\x1b[49m"], ["bgGreen", "\x1b[42m", "\x1b[49m"], ["bgYellow", "\x1b[43m", "\x1b[49m"], ["bgBlue", "\x1b[44m", "\x1b[49m"], ["bgMagenta", "\x1b[45m", "\x1b[49m"], ["bgCyan", "\x1b[46m", "\x1b[49m"], ["bgWhite", "\x1b[47m", "\x1b[49m"], ["blackBright", "\x1b[90m", "\x1b[39m"], ["redBright", "\x1b[91m", "\x1b[39m"], ["greenBright", "\x1b[92m", "\x1b[39m"], ["yellowBright", "\x1b[93m", "\x1b[39m"], ["blueBright", "\x1b[94m", "\x1b[39m"], ["magentaBright", "\x1b[95m", "\x1b[39m"], ["cyanBright", "\x1b[96m", "\x1b[39m"], ["whiteBright", "\x1b[97m", "\x1b[39m"], ["bgBlackBright", "\x1b[100m", "\x1b[49m"], ["bgRedBright", "\x1b[101m", "\x1b[49m"], ["bgGreenBright", "\x1b[102m", "\x1b[49m"], ["bgYellowBright", "\x1b[103m", "\x1b[49m"], ["bgBlueBright", "\x1b[104m", "\x1b[49m"], ["bgMagentaBright", "\x1b[105m", "\x1b[49m"], ["bgCyanBright", "\x1b[106m", "\x1b[49m"], ["bgWhiteBright", "\x1b[107m", "\x1b[49m"], ] test("colors", (t) => { t.plan(colors.length) colors.map(([name, open, close]) => t.equal(c[name](name), open + name + close, open + name + close) ) }) test("nesting", (t) => { t.plan(2) t.equal( c.bold(`bold ${c.red(`red ${c.dim("dim")} red`)} bold`), "\x1B[1mbold \x1B[31mred \x1B[2mdim\x1B[22m\x1B[1m red\x1B[39m bold\x1B[22m", "simple" ) t.equal( c.magenta( `magenta ${c.yellow( `yellow ${c.cyan("cyan")} ${c.red("red")} ${c.green("green")} yellow` )} magenta` ), "\x1B[35mmagenta \x1B[33myellow \x1B[36mcyan\x1B[33m \x1B[31mred\x1B[33m \x1B[32mgreen\x1B[33m yellow\x1B[35m magenta\x1B[39m", "complex" ) }) test("numbers & others", (t) => { const values = [new Date(), -1e10, -1, -0.1, 0, 0.1, 1, 1e10] t.plan(values.length) values.map((n) => t.equal(c.red(n), `\x1b[31m${n}\x1b[39m`)) }) test("empty & falsy values", (t) => { t.plan(9) t.equal(c.blue(), "", "nothing") t.equal(c.blue(""), "", '""') t.equal(c.blue(undefined), "", "undefined") t.equal(c.blue(0), "\x1b[34m0\x1b[39m", "0") t.equal(c.blue(NaN), "\x1b[34mNaN\x1b[39m", "NaN") t.equal(c.blue(null), "\x1b[34mnull\x1b[39m", "null") t.equal(c.blue(true), "\x1b[34mtrue\x1b[39m", "true") t.equal(c.blue(false), "\x1b[34mfalse\x1b[39m", "false") t.equal(c.blue(Infinity), "\x1b[34mInfinity\x1b[39m", "Infinity") }) test("createColors", (t) => { t.plan(2) t.equal( c.blue("megazord"), c.createColors({ useColor: true }).blue("megazord"), "useColor: true" ) t.equal( "megazord", c.createColors({ useColor: false }).blue("megazord"), "useColor: false" ) }) test("environment", (t) => { t.plan(4) exec( `FORCE_COLOR= node --print --eval ' require("./index.cjs").blue("foo") '`, (_, out) => t.equal(out, "\x1B[34mfoo\x1B[39m\n", "FORCE_COLOR") ) exec( `NO_COLOR= node --print --eval ' process.argv.push("--color") require("./index.cjs").blue("foo") '`, (_, out) => t.equal(out, "foo\n", "NO_COLOR") ) exec( `FORCE_COLOR= node --print --eval ' process.argv.push("--no-color") require("./index.cjs").blue("foo") '`, (_, out) => t.equal(out, "foo\n", "--no-color") ) exec( `FORCE_COLOR= node --print --eval ' process.argv.push("--color") require("./index.cjs").blue("foo") '`, (_, out) => t.equal(out, "\x1B[34mfoo\x1B[39m\n", "--color") ) }) colorette-2.0.16/tests/index.test.js000066400000000000000000000057671412762755600174230ustar00rootroot00000000000000import * as c from "../index.js" import { t, equal } from "twist" const colors = [ ["reset", "\x1b[0m", "\x1b[0m"], ["bold", "\x1b[1m", "\x1b[22m"], ["dim", "\x1b[2m", "\x1b[22m"], ["italic", "\x1b[3m", "\x1b[23m"], ["underline", "\x1b[4m", "\x1b[24m"], ["inverse", "\x1b[7m", "\x1b[27m"], ["hidden", "\x1b[8m", "\x1b[28m"], ["strikethrough", "\x1b[9m", "\x1b[29m"], ["black", "\x1b[30m", "\x1b[39m"], ["red", "\x1b[31m", "\x1b[39m"], ["green", "\x1b[32m", "\x1b[39m"], ["yellow", "\x1b[33m", "\x1b[39m"], ["blue", "\x1b[34m", "\x1b[39m"], ["magenta", "\x1b[35m", "\x1b[39m"], ["cyan", "\x1b[36m", "\x1b[39m"], ["white", "\x1b[37m", "\x1b[39m"], ["gray", "\x1b[90m", "\x1b[39m"], ["bgBlack", "\x1b[40m", "\x1b[49m"], ["bgRed", "\x1b[41m", "\x1b[49m"], ["bgGreen", "\x1b[42m", "\x1b[49m"], ["bgYellow", "\x1b[43m", "\x1b[49m"], ["bgBlue", "\x1b[44m", "\x1b[49m"], ["bgMagenta", "\x1b[45m", "\x1b[49m"], ["bgCyan", "\x1b[46m", "\x1b[49m"], ["bgWhite", "\x1b[47m", "\x1b[49m"], ["blackBright", "\x1b[90m", "\x1b[39m"], ["redBright", "\x1b[91m", "\x1b[39m"], ["greenBright", "\x1b[92m", "\x1b[39m"], ["yellowBright", "\x1b[93m", "\x1b[39m"], ["blueBright", "\x1b[94m", "\x1b[39m"], ["magentaBright", "\x1b[95m", "\x1b[39m"], ["cyanBright", "\x1b[96m", "\x1b[39m"], ["whiteBright", "\x1b[97m", "\x1b[39m"], ["bgBlackBright", "\x1b[100m", "\x1b[49m"], ["bgRedBright", "\x1b[101m", "\x1b[49m"], ["bgGreenBright", "\x1b[102m", "\x1b[49m"], ["bgYellowBright", "\x1b[103m", "\x1b[49m"], ["bgBlueBright", "\x1b[104m", "\x1b[49m"], ["bgMagentaBright", "\x1b[105m", "\x1b[49m"], ["bgCyanBright", "\x1b[106m", "\x1b[49m"], ["bgWhiteBright", "\x1b[107m", "\x1b[49m"], ] export default [ t("colorette", [ t("simple", [ ...colors.map(([name, open, close]) => equal(c[name](name), open + name + close) ), ]), t("nesting", [ equal( c.bold(`bold ${c.red(`red ${c.dim("dim")} red`)} bold`), "\x1B[1mbold \x1B[31mred \x1B[2mdim\x1B[22m\x1B[1m red\x1B[39m bold\x1B[22m" ), equal( c.magenta( `magenta ${c.yellow( `yellow ${c.cyan("cyan")} ${c.red("red")} ${c.green( "green" )} yellow` )} magenta` ), "\x1B[35mmagenta \x1B[33myellow \x1B[36mcyan\x1B[33m \x1B[31mred\x1B[33m \x1B[32mgreen\x1B[33m yellow\x1B[35m magenta\x1B[39m" ), ]), t("numbers & others", [ ...[new Date(), -1e10, -1, -0.1, 0, 0.1, 1, 1e10].map((n) => equal(c.red(n), `\x1b[31m${n}\x1b[39m`) ), ]), t("empty & falsy values", [ equal(c.blue(), ""), equal(c.blue(""), ""), equal(c.blue(undefined), ""), equal(c.blue(0), "\x1b[34m0\x1b[39m"), equal(c.blue(NaN), "\x1b[34mNaN\x1b[39m"), equal(c.blue(null), "\x1b[34mnull\x1b[39m"), equal(c.blue(true), "\x1b[34mtrue\x1b[39m"), equal(c.blue(false), "\x1b[34mfalse\x1b[39m"), equal(c.blue(Infinity), "\x1b[34mInfinity\x1b[39m"), ]), ]), ] colorette-2.0.16/tests/scripts/000077500000000000000000000000001412762755600164505ustar00rootroot00000000000000colorette-2.0.16/tests/scripts/--color.sh000066400000000000000000000001201412762755600202450ustar00rootroot00000000000000#!/bin/sh [ `./tests/scripts/bin.js --color` = `printf '\e[34mfoo\e[39m'` ] colorette-2.0.16/tests/scripts/--no-color.sh000066400000000000000000000001051412762755600206620ustar00rootroot00000000000000#!/bin/sh [ `FORCE_COLOR= ./tests/scripts/bin.js --no-color` = foo ]colorette-2.0.16/tests/scripts/FORCE_COLOR.sh000066400000000000000000000001211412762755600205720ustar00rootroot00000000000000#!/bin/sh [ `FORCE_COLOR= ./tests/scripts/bin.js` = `printf '\e[34mfoo\e[39m'` ]colorette-2.0.16/tests/scripts/NO_COLOR.sh000077500000000000000000000001001412762755600202500ustar00rootroot00000000000000#!/bin/sh [ `NO_COLOR= ./tests/scripts/bin.js --color` = foo ] colorette-2.0.16/tests/scripts/bin.js000077500000000000000000000001251412762755600175570ustar00rootroot00000000000000#!/usr/bin/env node import { blue } from "../../index.js" console.log(blue("foo"))