Skip to content

Commit

Permalink
Require Node.js 14
Browse files Browse the repository at this point in the history
  • Loading branch information
sindresorhus committed Dec 26, 2022
1 parent fc9ac0c commit 06d7035
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 19 deletions.
5 changes: 3 additions & 2 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,11 @@ jobs:
fail-fast: false
matrix:
node-version:
- 18
- 16
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v2
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
- run: npm install
Expand Down
8 changes: 4 additions & 4 deletions index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ Terminal string styling with [tagged template literals](https://developer.mozill
```
import chalkTemplate from 'chalk-template';
log(chalkTemplate`
console.log(chalkTemplate`
CPU: {red ${cpu.totalPercent}%}
RAM: {green ${ram.used / ram.total * 100}%}
DISK: {rgb(255,131,0) ${disk.used / disk.total * 100}%}
Expand All @@ -17,7 +17,7 @@ DISK: {rgb(255,131,0) ${disk.used / disk.total * 100}%}
import chalkTemplate from 'chalk-template';
import chalk from 'chalk';
log(chalk.red.bgBlack(chalkTemplate`2 + 3 = {bold ${2 + 3}}`));
console.log(chalk.red.bgBlack(chalkTemplate`2 + 3 = {bold ${2 + 3}}`));
```
*/
export default function chalkTemplate(text: TemplateStringsArray, ...placeholders: unknown[]): string;
Expand All @@ -30,7 +30,7 @@ configured for standard error instead of standard output
```
import {chalkTemplateStderr as chalkTemplate} from 'chalk-template';
log(chalkTemplate`
console.log(chalkTemplate`
CPU: {red ${cpu.totalPercent}%}
RAM: {green ${ram.used / ram.total * 100}%}
DISK: {rgb(255,131,0) ${disk.used / disk.total * 100}%}
Expand All @@ -42,7 +42,7 @@ DISK: {rgb(255,131,0) ${disk.used / disk.total * 100}%}
import {chalkTemplateStderr as chalkTemplate} from 'chalk-template';
import {chalkStderr as chalk} from 'chalk';
log(chalk.red.bgBlack(chalkTemplate`2 + 3 = {bold ${2 + 3}}`));
console.log(chalk.red.bgBlack(chalkTemplate`2 + 3 = {bold ${2 + 3}}`));
```
*/
export function chalkTemplateStderr(text: TemplateStringsArray, ...placeholders: unknown[]): string;
Expand Down
2 changes: 1 addition & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ function unescape(c) {
const bracket = c[1] === '{';

if ((u && !bracket && c.length === 5) || (c[0] === 'x' && c.length === 3)) {
return String.fromCharCode(Number.parseInt(c.slice(1), 16));
return String.fromCodePoint(Number.parseInt(c.slice(1), 16));
}

if (u && bracket) {
Expand Down
13 changes: 8 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,12 @@
"repository": "chalk/chalk-template",
"funding": "https://github.com/chalk/chalk-template?sponsor=1",
"type": "module",
"exports": "./index.js",
"exports": {
"types": "./index.d.ts",
"default": "./index.js"
},
"engines": {
"node": ">=12"
"node": ">=14.16"
},
"scripts": {
"test": "xo && ava test/index.js && cross-env FORCE_COLOR=0 ava test/no-color.js && cross-env FORCE_COLOR=3 TERM=dumb ava test/full-color.js && cross-env FORCE_COLOR=3 TERM=dumb ava test/template.js && tsd"
Expand Down Expand Up @@ -46,9 +49,9 @@
"chalk": "^4.1.2"
},
"devDependencies": {
"ava": "^3.15.0",
"ava": "^5.1.0",
"cross-env": "^7.0.3",
"tsd": "^0.18.0",
"xo": "^0.45.0"
"tsd": "^0.25.0",
"xo": "^0.53.1"
}
}
10 changes: 3 additions & 7 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,13 @@ For printing to standard output (stdout):
import chalkTemplate from 'chalk-template';
import chalk from 'chalk';

const log = console.log;

log(chalkTemplate`
console.log(chalkTemplate`
CPU: {red ${cpu.totalPercent}%}
RAM: {green ${ram.used / ram.total * 100}%}
DISK: {rgb(255,131,0) ${disk.used / disk.total * 100}%}
`);

log(chalk.red.bgBlack(chalkTemplate`2 + 3 = {bold ${2 + 3}}`));
console.log(chalk.red.bgBlack(chalkTemplate`2 + 3 = {bold ${2 + 3}}`));

const miles = 18;
const calculateFeet = miles => miles * 5280;
Expand All @@ -46,9 +44,7 @@ For printing to standard error (stderr):
```js
import {chalkTemplateStderr} from 'chalk-template';

const error = console.error;

error(chalkTemplateStderr`
console.error(chalkTemplateStderr`
CPU: {red ${cpu.totalPercent}%}
RAM: {green ${ram.used / ram.total * 100}%}
DISK: {rgb(255,131,0) ${disk.used / disk.total * 100}%}
Expand Down

0 comments on commit 06d7035

Please sign in to comment.