-
-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Co-authored-by: Sindre Sorhus <[email protected]>
- Loading branch information
1 parent
c0ddf60
commit ce0999f
Showing
10 changed files
with
282 additions
and
215 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
name: CI | ||
on: | ||
- push | ||
- pull_request | ||
jobs: | ||
test: | ||
name: Node.js ${{ matrix.node-version }} | ||
runs-on: ubuntu-latest | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
node-version: | ||
- 16 | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- uses: actions/setup-node@v2 | ||
with: | ||
node-version: ${{ matrix.node-version }} | ||
- run: npm install | ||
- run: npm test |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
/** | ||
Terminal string styling with [tagged template literals](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Template_literals#tagged_templates) | ||
@example | ||
``` | ||
import chalkTemplate from 'chalk-template'; | ||
log(chalkTemplate` | ||
CPU: {red ${cpu.totalPercent}%} | ||
RAM: {green ${ram.used / ram.total * 100}%} | ||
DISK: {rgb(255,131,0) ${disk.used / disk.total * 100}%} | ||
`); | ||
``` | ||
@example | ||
``` | ||
import chalkTemplate from 'chalk-template'; | ||
import chalk from 'chalk'; | ||
log(chalk.red.bgBlack(chalkTemplate`2 + 3 = {bold ${2 + 3}}`)); | ||
``` | ||
*/ | ||
export default function chalkTemplate(text: TemplateStringsArray, ...placeholders: unknown[]): string; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import {expectType} from 'tsd'; | ||
import chalk from 'chalk'; | ||
import chalkTemplate from './index.js'; | ||
|
||
// -- Template literal -- | ||
expectType<string>(chalkTemplate``); | ||
const name = 'John'; | ||
expectType<string>(chalkTemplate`Hello {bold.red ${name}}`); | ||
expectType<string>(chalkTemplate`Works with numbers {bold.red ${1}}`); | ||
|
||
// -- Complex template literal -- | ||
expectType<string>(chalk.red.bgGreen.bold(chalkTemplate`Hello {italic.blue ${name}}`)); | ||
expectType<string>(chalk.strikethrough.cyanBright.bgBlack(chalkTemplate`Works with {reset {bold numbers}} {bold.red ${1}}`)); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.