immosquare-cleaner 0.1.23 → 0.1.24
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/immosquare-cleaner/version.rb +1 -1
- data/linters/rubocop-3.2.2.yml +1 -0
- data/linters/rubocop.yml +2 -0
- data/node_modules/@eslint-community/eslint-utils/node_modules/eslint/node_modules/@eslint/eslintrc/LICENSE +19 -0
- data/node_modules/@eslint-community/eslint-utils/node_modules/eslint/node_modules/@eslint/eslintrc/README.md +71 -0
- data/node_modules/@eslint-community/eslint-utils/node_modules/eslint/node_modules/@eslint/eslintrc/conf/config-schema.js +79 -0
- data/node_modules/@eslint-community/eslint-utils/node_modules/eslint/node_modules/@eslint/eslintrc/conf/environments.js +215 -0
- data/node_modules/@eslint-community/eslint-utils/node_modules/eslint/node_modules/@eslint/eslintrc/dist/eslintrc-universal.cjs +1104 -0
- data/node_modules/@eslint-community/eslint-utils/node_modules/eslint/node_modules/@eslint/eslintrc/dist/eslintrc-universal.cjs.map +1 -0
- data/node_modules/@eslint-community/eslint-utils/node_modules/eslint/node_modules/@eslint/eslintrc/dist/eslintrc.cjs +4333 -0
- data/node_modules/@eslint-community/eslint-utils/node_modules/eslint/node_modules/@eslint/eslintrc/dist/eslintrc.cjs.map +1 -0
- data/node_modules/@eslint-community/eslint-utils/node_modules/eslint/node_modules/@eslint/eslintrc/lib/cascading-config-array-factory.js +532 -0
- data/node_modules/@eslint-community/eslint-utils/node_modules/eslint/node_modules/@eslint/eslintrc/lib/config-array/config-array.js +523 -0
- data/node_modules/@eslint-community/eslint-utils/node_modules/eslint/node_modules/@eslint/eslintrc/lib/config-array/config-dependency.js +115 -0
- data/node_modules/@eslint-community/eslint-utils/node_modules/eslint/node_modules/@eslint/eslintrc/lib/config-array/extracted-config.js +145 -0
- data/node_modules/@eslint-community/eslint-utils/node_modules/eslint/node_modules/@eslint/eslintrc/lib/config-array/ignore-pattern.js +238 -0
- data/node_modules/@eslint-community/eslint-utils/node_modules/eslint/node_modules/@eslint/eslintrc/lib/config-array/index.js +19 -0
- data/node_modules/@eslint-community/eslint-utils/node_modules/eslint/node_modules/@eslint/eslintrc/lib/config-array/override-tester.js +225 -0
- data/node_modules/@eslint-community/eslint-utils/node_modules/eslint/node_modules/@eslint/eslintrc/lib/config-array-factory.js +1149 -0
- data/node_modules/@eslint-community/eslint-utils/node_modules/eslint/node_modules/@eslint/eslintrc/lib/flat-compat.js +318 -0
- data/node_modules/@eslint-community/eslint-utils/node_modules/eslint/node_modules/@eslint/eslintrc/lib/index-universal.js +29 -0
- data/node_modules/@eslint-community/eslint-utils/node_modules/eslint/node_modules/@eslint/eslintrc/lib/index.js +56 -0
- data/node_modules/@eslint-community/eslint-utils/node_modules/eslint/node_modules/@eslint/eslintrc/lib/shared/ajv.js +191 -0
- data/node_modules/@eslint-community/eslint-utils/node_modules/eslint/node_modules/@eslint/eslintrc/lib/shared/config-ops.js +135 -0
- data/node_modules/@eslint-community/eslint-utils/node_modules/eslint/node_modules/@eslint/eslintrc/lib/shared/config-validator.js +325 -0
- data/node_modules/@eslint-community/eslint-utils/node_modules/eslint/node_modules/@eslint/eslintrc/lib/shared/deprecation-warnings.js +63 -0
- data/node_modules/@eslint-community/eslint-utils/node_modules/eslint/node_modules/@eslint/eslintrc/lib/shared/naming.js +96 -0
- data/node_modules/@eslint-community/eslint-utils/node_modules/eslint/node_modules/@eslint/eslintrc/lib/shared/relative-module-resolver.js +42 -0
- data/node_modules/@eslint-community/eslint-utils/node_modules/eslint/node_modules/@eslint/eslintrc/lib/shared/types.js +149 -0
- data/node_modules/@eslint-community/eslint-utils/node_modules/eslint/node_modules/@eslint/eslintrc/node_modules/strip-json-comments/index.d.ts +36 -0
- data/node_modules/@eslint-community/eslint-utils/node_modules/eslint/node_modules/@eslint/eslintrc/node_modules/strip-json-comments/index.js +77 -0
- data/node_modules/@eslint-community/eslint-utils/node_modules/eslint/node_modules/@eslint/eslintrc/node_modules/strip-json-comments/license +9 -0
- data/node_modules/@eslint-community/eslint-utils/node_modules/eslint/node_modules/@eslint/eslintrc/node_modules/strip-json-comments/package.json +47 -0
- data/node_modules/@eslint-community/eslint-utils/node_modules/eslint/node_modules/@eslint/eslintrc/node_modules/strip-json-comments/readme.md +78 -0
- data/node_modules/@eslint-community/eslint-utils/node_modules/eslint/node_modules/@eslint/eslintrc/package.json +82 -0
- data/node_modules/@eslint-community/eslint-utils/node_modules/eslint/node_modules/@eslint/eslintrc/universal.js +9 -0
- data/node_modules/@eslint-community/eslint-utils/node_modules/eslint/node_modules/@eslint/js/LICENSE +19 -0
- data/node_modules/@eslint-community/eslint-utils/node_modules/eslint/node_modules/@eslint/js/README.md +57 -0
- data/node_modules/@eslint-community/eslint-utils/node_modules/eslint/node_modules/@eslint/js/package.json +31 -0
- data/node_modules/@eslint-community/eslint-utils/node_modules/eslint/node_modules/@eslint/js/src/configs/eslint-all.js +278 -0
- data/node_modules/@eslint-community/eslint-utils/node_modules/eslint/node_modules/@eslint/js/src/configs/eslint-recommended.js +76 -0
- data/node_modules/@eslint-community/eslint-utils/node_modules/eslint/node_modules/@eslint/js/src/index.js +17 -0
- data/node_modules/@eslint-community/eslint-utils/node_modules/eslint/node_modules/@humanwhocodes/config-array/LICENSE +201 -0
- data/node_modules/@eslint-community/eslint-utils/node_modules/eslint/node_modules/@humanwhocodes/config-array/README.md +342 -0
- data/node_modules/@eslint-community/eslint-utils/node_modules/eslint/node_modules/@humanwhocodes/config-array/api.js +1061 -0
- data/node_modules/@eslint-community/eslint-utils/node_modules/eslint/node_modules/@humanwhocodes/config-array/node_modules/@humanwhocodes/object-schema/CHANGELOG.md +8 -0
- data/node_modules/@eslint-community/eslint-utils/node_modules/eslint/node_modules/@humanwhocodes/config-array/node_modules/@humanwhocodes/object-schema/LICENSE +29 -0
- data/node_modules/@eslint-community/eslint-utils/node_modules/eslint/node_modules/@humanwhocodes/config-array/node_modules/@humanwhocodes/object-schema/README.md +234 -0
- data/node_modules/@eslint-community/eslint-utils/node_modules/eslint/node_modules/@humanwhocodes/config-array/node_modules/@humanwhocodes/object-schema/package.json +33 -0
- data/node_modules/@eslint-community/eslint-utils/node_modules/eslint/node_modules/@humanwhocodes/config-array/node_modules/@humanwhocodes/object-schema/src/index.js +7 -0
- data/node_modules/@eslint-community/eslint-utils/node_modules/eslint/node_modules/@humanwhocodes/config-array/node_modules/@humanwhocodes/object-schema/src/merge-strategy.js +53 -0
- data/node_modules/@eslint-community/eslint-utils/node_modules/eslint/node_modules/@humanwhocodes/config-array/node_modules/@humanwhocodes/object-schema/src/object-schema.js +235 -0
- data/node_modules/@eslint-community/eslint-utils/node_modules/eslint/node_modules/@humanwhocodes/config-array/node_modules/@humanwhocodes/object-schema/src/validation-strategy.js +102 -0
- data/node_modules/@eslint-community/eslint-utils/node_modules/eslint/node_modules/@humanwhocodes/config-array/node_modules/@humanwhocodes/object-schema/tests/merge-strategy.js +66 -0
- data/node_modules/@eslint-community/eslint-utils/node_modules/eslint/node_modules/@humanwhocodes/config-array/node_modules/@humanwhocodes/object-schema/tests/object-schema.js +611 -0
- data/node_modules/@eslint-community/eslint-utils/node_modules/eslint/node_modules/@humanwhocodes/config-array/node_modules/@humanwhocodes/object-schema/tests/validation-strategy.js +186 -0
- data/node_modules/@eslint-community/eslint-utils/node_modules/eslint/node_modules/@humanwhocodes/config-array/node_modules/minimatch/LICENSE +15 -0
- data/node_modules/@eslint-community/eslint-utils/node_modules/eslint/node_modules/@humanwhocodes/config-array/node_modules/minimatch/README.md +224 -0
- data/node_modules/@eslint-community/eslint-utils/node_modules/eslint/node_modules/@humanwhocodes/config-array/node_modules/minimatch/minimatch.js +947 -0
- data/node_modules/@eslint-community/eslint-utils/node_modules/eslint/node_modules/@humanwhocodes/config-array/node_modules/minimatch/node_modules/brace-expansion/LICENSE +21 -0
- data/node_modules/@eslint-community/eslint-utils/node_modules/eslint/node_modules/@humanwhocodes/config-array/node_modules/minimatch/node_modules/brace-expansion/README.md +129 -0
- data/node_modules/@eslint-community/eslint-utils/node_modules/eslint/node_modules/@humanwhocodes/config-array/node_modules/minimatch/node_modules/brace-expansion/index.js +201 -0
- data/node_modules/@eslint-community/eslint-utils/node_modules/eslint/node_modules/@humanwhocodes/config-array/node_modules/minimatch/node_modules/brace-expansion/package.json +47 -0
- data/node_modules/@eslint-community/eslint-utils/node_modules/eslint/node_modules/@humanwhocodes/config-array/node_modules/minimatch/package.json +33 -0
- data/node_modules/@eslint-community/eslint-utils/node_modules/eslint/node_modules/@humanwhocodes/config-array/package.json +61 -0
- data/node_modules/@eslint-community/eslint-utils/node_modules/eslint/node_modules/chalk/index.d.ts +415 -0
- data/node_modules/@eslint-community/eslint-utils/node_modules/eslint/node_modules/chalk/license +9 -0
- data/node_modules/@eslint-community/eslint-utils/node_modules/eslint/node_modules/chalk/package.json +68 -0
- data/node_modules/@eslint-community/eslint-utils/node_modules/eslint/node_modules/chalk/readme.md +341 -0
- data/node_modules/@eslint-community/eslint-utils/node_modules/eslint/node_modules/chalk/source/index.js +229 -0
- data/node_modules/@eslint-community/eslint-utils/node_modules/eslint/node_modules/chalk/source/templates.js +134 -0
- data/node_modules/@eslint-community/eslint-utils/node_modules/eslint/node_modules/chalk/source/util.js +39 -0
- data/node_modules/@eslint-community/eslint-utils/node_modules/eslint/node_modules/minimatch/LICENSE +15 -0
- data/node_modules/@eslint-community/eslint-utils/node_modules/eslint/node_modules/minimatch/README.md +230 -0
- data/node_modules/@eslint-community/eslint-utils/node_modules/eslint/node_modules/minimatch/minimatch.js +947 -0
- data/node_modules/@eslint-community/eslint-utils/node_modules/eslint/node_modules/minimatch/node_modules/brace-expansion/LICENSE +21 -0
- data/node_modules/@eslint-community/eslint-utils/node_modules/eslint/node_modules/minimatch/node_modules/brace-expansion/README.md +129 -0
- data/node_modules/@eslint-community/eslint-utils/node_modules/eslint/node_modules/minimatch/node_modules/brace-expansion/index.js +201 -0
- data/node_modules/@eslint-community/eslint-utils/node_modules/eslint/node_modules/minimatch/node_modules/brace-expansion/package.json +47 -0
- data/node_modules/@eslint-community/eslint-utils/node_modules/eslint/node_modules/minimatch/package.json +33 -0
- data/node_modules/@eslint-community/eslint-utils/node_modules/eslint/node_modules/strip-ansi/index.d.ts +17 -0
- data/node_modules/@eslint-community/eslint-utils/node_modules/eslint/node_modules/strip-ansi/index.js +4 -0
- data/node_modules/@eslint-community/eslint-utils/node_modules/eslint/node_modules/strip-ansi/license +9 -0
- data/node_modules/@eslint-community/eslint-utils/node_modules/eslint/node_modules/strip-ansi/node_modules/ansi-regex/index.d.ts +37 -0
- data/node_modules/@eslint-community/eslint-utils/node_modules/eslint/node_modules/strip-ansi/node_modules/ansi-regex/index.js +10 -0
- data/node_modules/@eslint-community/eslint-utils/node_modules/eslint/node_modules/strip-ansi/node_modules/ansi-regex/license +9 -0
- data/node_modules/@eslint-community/eslint-utils/node_modules/eslint/node_modules/strip-ansi/node_modules/ansi-regex/package.json +55 -0
- data/node_modules/@eslint-community/eslint-utils/node_modules/eslint/node_modules/strip-ansi/node_modules/ansi-regex/readme.md +78 -0
- data/node_modules/@eslint-community/eslint-utils/node_modules/eslint/node_modules/strip-ansi/package.json +54 -0
- data/node_modules/@eslint-community/eslint-utils/node_modules/eslint/node_modules/strip-ansi/readme.md +46 -0
- data/node_modules/eslint-plugin-import/node_modules/debug/node_modules/ms/index.js +162 -0
- data/node_modules/eslint-plugin-import/node_modules/debug/node_modules/ms/license.md +21 -0
- data/node_modules/eslint-plugin-import/node_modules/debug/node_modules/ms/package.json +38 -0
- data/node_modules/eslint-plugin-import/node_modules/debug/node_modules/ms/readme.md +59 -0
- data/node_modules/npm-check-updates/build/package.json +2 -3
- data/node_modules/npm-check-updates/build/src/lib/runGlobal.js +18 -11
- data/node_modules/npm-check-updates/build/src/lib/runGlobal.js.map +1 -1
- data/node_modules/npm-check-updates/build/src/package-managers/bun.js +2 -3
- data/node_modules/npm-check-updates/build/src/package-managers/bun.js.map +1 -1
- data/node_modules/npm-check-updates/build/src/package-managers/npm.js +12 -8
- data/node_modules/npm-check-updates/build/src/package-managers/npm.js.map +1 -1
- data/node_modules/npm-check-updates/build/src/package-managers/pnpm.js +37 -14
- data/node_modules/npm-check-updates/build/src/package-managers/pnpm.js.map +1 -1
- data/node_modules/npm-check-updates/build/src/package-managers/yarn.js +36 -11
- data/node_modules/npm-check-updates/build/src/package-managers/yarn.js.map +1 -1
- data/node_modules/npm-check-updates/package.json +2 -3
- data/node_modules/prettier/LICENSE +3 -3
- data/node_modules/prettier/index.cjs +1 -1
- data/node_modules/prettier/index.mjs +14 -22
- data/node_modules/prettier/package.json +1 -1
- data/node_modules/prettier/plugins/acorn.js +10 -10
- data/node_modules/prettier/plugins/acorn.mjs +10 -10
- data/node_modules/prettier/plugins/angular.js +1 -1
- data/node_modules/prettier/plugins/angular.mjs +1 -1
- data/node_modules/prettier/plugins/babel.js +8 -8
- data/node_modules/prettier/plugins/babel.mjs +8 -8
- data/node_modules/prettier/plugins/estree.js +24 -24
- data/node_modules/prettier/plugins/estree.mjs +24 -24
- data/node_modules/prettier/plugins/flow.js +17 -17
- data/node_modules/prettier/plugins/flow.mjs +17 -17
- data/node_modules/prettier/plugins/graphql.js +6 -6
- data/node_modules/prettier/plugins/graphql.mjs +6 -6
- data/node_modules/prettier/plugins/html.js +1 -1
- data/node_modules/prettier/plugins/html.mjs +1 -1
- data/node_modules/prettier/plugins/markdown.js +1 -1
- data/node_modules/prettier/plugins/markdown.mjs +1 -1
- data/node_modules/prettier/plugins/meriyah.js +4 -4
- data/node_modules/prettier/plugins/meriyah.mjs +4 -4
- data/node_modules/prettier/plugins/typescript.js +19 -19
- data/node_modules/prettier/plugins/typescript.mjs +19 -19
- data/node_modules/prettier/standalone.js +10 -10
- data/node_modules/prettier/standalone.mjs +9 -9
- data/package.json +2 -2
- metadata +95 -4
data/node_modules/@eslint-community/eslint-utils/node_modules/eslint/node_modules/chalk/readme.md
ADDED
@@ -0,0 +1,341 @@
|
|
1
|
+
<h1 align="center">
|
2
|
+
<br>
|
3
|
+
<br>
|
4
|
+
<img width="320" src="media/logo.svg" alt="Chalk">
|
5
|
+
<br>
|
6
|
+
<br>
|
7
|
+
<br>
|
8
|
+
</h1>
|
9
|
+
|
10
|
+
> Terminal string styling done right
|
11
|
+
|
12
|
+
[![Build Status](https://travis-ci.org/chalk/chalk.svg?branch=master)](https://travis-ci.org/chalk/chalk) [![Coverage Status](https://coveralls.io/repos/github/chalk/chalk/badge.svg?branch=master)](https://coveralls.io/github/chalk/chalk?branch=master) [![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) [![](https://img.shields.io/badge/unicorn-approved-ff69b4.svg)](https://www.youtube.com/watch?v=9auOCbH5Ns4) [![XO code style](https://img.shields.io/badge/code_style-XO-5ed9c7.svg)](https://github.com/xojs/xo) ![TypeScript-ready](https://img.shields.io/npm/types/chalk.svg) [![run on repl.it](https://repl.it/badge/github/chalk/chalk)](https://repl.it/github/chalk/chalk)
|
13
|
+
|
14
|
+
<img src="https://cdn.jsdelivr.net/gh/chalk/ansi-styles@8261697c95bf34b6c7767e2cbe9941a851d59385/screenshot.svg" width="900">
|
15
|
+
|
16
|
+
<br>
|
17
|
+
|
18
|
+
---
|
19
|
+
|
20
|
+
<div align="center">
|
21
|
+
<p>
|
22
|
+
<p>
|
23
|
+
<sup>
|
24
|
+
Sindre Sorhus' open source work is supported by the community on <a href="https://github.com/sponsors/sindresorhus">GitHub Sponsors</a> and <a href="https://stakes.social/0x44d871aebF0126Bf646753E2C976Aa7e68A66c15">Dev</a>
|
25
|
+
</sup>
|
26
|
+
</p>
|
27
|
+
<sup>Special thanks to:</sup>
|
28
|
+
<br>
|
29
|
+
<br>
|
30
|
+
<a href="https://standardresume.co/tech">
|
31
|
+
<img src="https://sindresorhus.com/assets/thanks/standard-resume-logo.svg" width="160"/>
|
32
|
+
</a>
|
33
|
+
<br>
|
34
|
+
<br>
|
35
|
+
<a href="https://retool.com/?utm_campaign=sindresorhus">
|
36
|
+
<img src="https://sindresorhus.com/assets/thanks/retool-logo.svg" width="230"/>
|
37
|
+
</a>
|
38
|
+
<br>
|
39
|
+
<br>
|
40
|
+
<a href="https://doppler.com/?utm_campaign=github_repo&utm_medium=referral&utm_content=chalk&utm_source=github">
|
41
|
+
<div>
|
42
|
+
<img src="https://dashboard.doppler.com/imgs/logo-long.svg" width="240" alt="Doppler">
|
43
|
+
</div>
|
44
|
+
<b>All your environment variables, in one place</b>
|
45
|
+
<div>
|
46
|
+
<span>Stop struggling with scattered API keys, hacking together home-brewed tools,</span>
|
47
|
+
<br>
|
48
|
+
<span>and avoiding access controls. Keep your team and servers in sync with Doppler.</span>
|
49
|
+
</div>
|
50
|
+
</a>
|
51
|
+
<br>
|
52
|
+
<a href="https://uibakery.io/?utm_source=chalk&utm_medium=sponsor&utm_campaign=github">
|
53
|
+
<div>
|
54
|
+
<img src="https://sindresorhus.com/assets/thanks/uibakery-logo.jpg" width="270" alt="UI Bakery">
|
55
|
+
</div>
|
56
|
+
</a>
|
57
|
+
</p>
|
58
|
+
</div>
|
59
|
+
|
60
|
+
---
|
61
|
+
|
62
|
+
<br>
|
63
|
+
|
64
|
+
## Highlights
|
65
|
+
|
66
|
+
- Expressive API
|
67
|
+
- Highly performant
|
68
|
+
- Ability to nest styles
|
69
|
+
- [256/Truecolor color support](#256-and-truecolor-color-support)
|
70
|
+
- Auto-detects color support
|
71
|
+
- Doesn't extend `String.prototype`
|
72
|
+
- Clean and focused
|
73
|
+
- Actively maintained
|
74
|
+
- [Used by ~50,000 packages](https://www.npmjs.com/browse/depended/chalk) as of January 1, 2020
|
75
|
+
|
76
|
+
## Install
|
77
|
+
|
78
|
+
```console
|
79
|
+
$ npm install chalk
|
80
|
+
```
|
81
|
+
|
82
|
+
## Usage
|
83
|
+
|
84
|
+
```js
|
85
|
+
const chalk = require('chalk');
|
86
|
+
|
87
|
+
console.log(chalk.blue('Hello world!'));
|
88
|
+
```
|
89
|
+
|
90
|
+
Chalk comes with an easy to use composable API where you just chain and nest the styles you want.
|
91
|
+
|
92
|
+
```js
|
93
|
+
const chalk = require('chalk');
|
94
|
+
const log = console.log;
|
95
|
+
|
96
|
+
// Combine styled and normal strings
|
97
|
+
log(chalk.blue('Hello') + ' World' + chalk.red('!'));
|
98
|
+
|
99
|
+
// Compose multiple styles using the chainable API
|
100
|
+
log(chalk.blue.bgRed.bold('Hello world!'));
|
101
|
+
|
102
|
+
// Pass in multiple arguments
|
103
|
+
log(chalk.blue('Hello', 'World!', 'Foo', 'bar', 'biz', 'baz'));
|
104
|
+
|
105
|
+
// Nest styles
|
106
|
+
log(chalk.red('Hello', chalk.underline.bgBlue('world') + '!'));
|
107
|
+
|
108
|
+
// Nest styles of the same type even (color, underline, background)
|
109
|
+
log(chalk.green(
|
110
|
+
'I am a green line ' +
|
111
|
+
chalk.blue.underline.bold('with a blue substring') +
|
112
|
+
' that becomes green again!'
|
113
|
+
));
|
114
|
+
|
115
|
+
// ES2015 template literal
|
116
|
+
log(`
|
117
|
+
CPU: ${chalk.red('90%')}
|
118
|
+
RAM: ${chalk.green('40%')}
|
119
|
+
DISK: ${chalk.yellow('70%')}
|
120
|
+
`);
|
121
|
+
|
122
|
+
// ES2015 tagged template literal
|
123
|
+
log(chalk`
|
124
|
+
CPU: {red ${cpu.totalPercent}%}
|
125
|
+
RAM: {green ${ram.used / ram.total * 100}%}
|
126
|
+
DISK: {rgb(255,131,0) ${disk.used / disk.total * 100}%}
|
127
|
+
`);
|
128
|
+
|
129
|
+
// Use RGB colors in terminal emulators that support it.
|
130
|
+
log(chalk.keyword('orange')('Yay for orange colored text!'));
|
131
|
+
log(chalk.rgb(123, 45, 67).underline('Underlined reddish color'));
|
132
|
+
log(chalk.hex('#DEADED').bold('Bold gray!'));
|
133
|
+
```
|
134
|
+
|
135
|
+
Easily define your own themes:
|
136
|
+
|
137
|
+
```js
|
138
|
+
const chalk = require('chalk');
|
139
|
+
|
140
|
+
const error = chalk.bold.red;
|
141
|
+
const warning = chalk.keyword('orange');
|
142
|
+
|
143
|
+
console.log(error('Error!'));
|
144
|
+
console.log(warning('Warning!'));
|
145
|
+
```
|
146
|
+
|
147
|
+
Take advantage of console.log [string substitution](https://nodejs.org/docs/latest/api/console.html#console_console_log_data_args):
|
148
|
+
|
149
|
+
```js
|
150
|
+
const name = 'Sindre';
|
151
|
+
console.log(chalk.green('Hello %s'), name);
|
152
|
+
//=> 'Hello Sindre'
|
153
|
+
```
|
154
|
+
|
155
|
+
## API
|
156
|
+
|
157
|
+
### chalk.`<style>[.<style>...](string, [string...])`
|
158
|
+
|
159
|
+
Example: `chalk.red.bold.underline('Hello', 'world');`
|
160
|
+
|
161
|
+
Chain [styles](#styles) and call the last one as a method with a string argument. Order doesn't matter, and later styles take precedent in case of a conflict. This simply means that `chalk.red.yellow.green` is equivalent to `chalk.green`.
|
162
|
+
|
163
|
+
Multiple arguments will be separated by space.
|
164
|
+
|
165
|
+
### chalk.level
|
166
|
+
|
167
|
+
Specifies the level of color support.
|
168
|
+
|
169
|
+
Color support is automatically detected, but you can override it by setting the `level` property. You should however only do this in your own code as it applies globally to all Chalk consumers.
|
170
|
+
|
171
|
+
If you need to change this in a reusable module, create a new instance:
|
172
|
+
|
173
|
+
```js
|
174
|
+
const ctx = new chalk.Instance({level: 0});
|
175
|
+
```
|
176
|
+
|
177
|
+
| Level | Description |
|
178
|
+
| :---: | :--- |
|
179
|
+
| `0` | All colors disabled |
|
180
|
+
| `1` | Basic color support (16 colors) |
|
181
|
+
| `2` | 256 color support |
|
182
|
+
| `3` | Truecolor support (16 million colors) |
|
183
|
+
|
184
|
+
### chalk.supportsColor
|
185
|
+
|
186
|
+
Detect whether the terminal [supports color](https://github.com/chalk/supports-color). Used internally and handled for you, but exposed for convenience.
|
187
|
+
|
188
|
+
Can be overridden by the user with the flags `--color` and `--no-color`. For situations where using `--color` is not possible, use the environment variable `FORCE_COLOR=1` (level 1), `FORCE_COLOR=2` (level 2), or `FORCE_COLOR=3` (level 3) to forcefully enable color, or `FORCE_COLOR=0` to forcefully disable. The use of `FORCE_COLOR` overrides all other color support checks.
|
189
|
+
|
190
|
+
Explicit 256/Truecolor mode can be enabled using the `--color=256` and `--color=16m` flags, respectively.
|
191
|
+
|
192
|
+
### chalk.stderr and chalk.stderr.supportsColor
|
193
|
+
|
194
|
+
`chalk.stderr` contains a separate instance configured with color support detected for `stderr` stream instead of `stdout`. Override rules from `chalk.supportsColor` apply to this too. `chalk.stderr.supportsColor` is exposed for convenience.
|
195
|
+
|
196
|
+
## Styles
|
197
|
+
|
198
|
+
### Modifiers
|
199
|
+
|
200
|
+
- `reset` - Resets the current color chain.
|
201
|
+
- `bold` - Make text bold.
|
202
|
+
- `dim` - Emitting only a small amount of light.
|
203
|
+
- `italic` - Make text italic. *(Not widely supported)*
|
204
|
+
- `underline` - Make text underline. *(Not widely supported)*
|
205
|
+
- `inverse`- Inverse background and foreground colors.
|
206
|
+
- `hidden` - Prints the text, but makes it invisible.
|
207
|
+
- `strikethrough` - Puts a horizontal line through the center of the text. *(Not widely supported)*
|
208
|
+
- `visible`- Prints the text only when Chalk has a color level > 0. Can be useful for things that are purely cosmetic.
|
209
|
+
|
210
|
+
### Colors
|
211
|
+
|
212
|
+
- `black`
|
213
|
+
- `red`
|
214
|
+
- `green`
|
215
|
+
- `yellow`
|
216
|
+
- `blue`
|
217
|
+
- `magenta`
|
218
|
+
- `cyan`
|
219
|
+
- `white`
|
220
|
+
- `blackBright` (alias: `gray`, `grey`)
|
221
|
+
- `redBright`
|
222
|
+
- `greenBright`
|
223
|
+
- `yellowBright`
|
224
|
+
- `blueBright`
|
225
|
+
- `magentaBright`
|
226
|
+
- `cyanBright`
|
227
|
+
- `whiteBright`
|
228
|
+
|
229
|
+
### Background colors
|
230
|
+
|
231
|
+
- `bgBlack`
|
232
|
+
- `bgRed`
|
233
|
+
- `bgGreen`
|
234
|
+
- `bgYellow`
|
235
|
+
- `bgBlue`
|
236
|
+
- `bgMagenta`
|
237
|
+
- `bgCyan`
|
238
|
+
- `bgWhite`
|
239
|
+
- `bgBlackBright` (alias: `bgGray`, `bgGrey`)
|
240
|
+
- `bgRedBright`
|
241
|
+
- `bgGreenBright`
|
242
|
+
- `bgYellowBright`
|
243
|
+
- `bgBlueBright`
|
244
|
+
- `bgMagentaBright`
|
245
|
+
- `bgCyanBright`
|
246
|
+
- `bgWhiteBright`
|
247
|
+
|
248
|
+
## Tagged template literal
|
249
|
+
|
250
|
+
Chalk can be used as a [tagged template literal](https://exploringjs.com/es6/ch_template-literals.html#_tagged-template-literals).
|
251
|
+
|
252
|
+
```js
|
253
|
+
const chalk = require('chalk');
|
254
|
+
|
255
|
+
const miles = 18;
|
256
|
+
const calculateFeet = miles => miles * 5280;
|
257
|
+
|
258
|
+
console.log(chalk`
|
259
|
+
There are {bold 5280 feet} in a mile.
|
260
|
+
In {bold ${miles} miles}, there are {green.bold ${calculateFeet(miles)} feet}.
|
261
|
+
`);
|
262
|
+
```
|
263
|
+
|
264
|
+
Blocks are delimited by an opening curly brace (`{`), a style, some content, and a closing curly brace (`}`).
|
265
|
+
|
266
|
+
Template styles are chained exactly like normal Chalk styles. The following three statements are equivalent:
|
267
|
+
|
268
|
+
```js
|
269
|
+
console.log(chalk.bold.rgb(10, 100, 200)('Hello!'));
|
270
|
+
console.log(chalk.bold.rgb(10, 100, 200)`Hello!`);
|
271
|
+
console.log(chalk`{bold.rgb(10,100,200) Hello!}`);
|
272
|
+
```
|
273
|
+
|
274
|
+
Note that function styles (`rgb()`, `hsl()`, `keyword()`, etc.) may not contain spaces between parameters.
|
275
|
+
|
276
|
+
All interpolated values (`` chalk`${foo}` ``) are converted to strings via the `.toString()` method. All curly braces (`{` and `}`) in interpolated value strings are escaped.
|
277
|
+
|
278
|
+
## 256 and Truecolor color support
|
279
|
+
|
280
|
+
Chalk supports 256 colors and [Truecolor](https://gist.github.com/XVilka/8346728) (16 million colors) on supported terminal apps.
|
281
|
+
|
282
|
+
Colors are downsampled from 16 million RGB values to an ANSI color format that is supported by the terminal emulator (or by specifying `{level: n}` as a Chalk option). For example, Chalk configured to run at level 1 (basic color support) will downsample an RGB value of #FF0000 (red) to 31 (ANSI escape for red).
|
283
|
+
|
284
|
+
Examples:
|
285
|
+
|
286
|
+
- `chalk.hex('#DEADED').underline('Hello, world!')`
|
287
|
+
- `chalk.keyword('orange')('Some orange text')`
|
288
|
+
- `chalk.rgb(15, 100, 204).inverse('Hello!')`
|
289
|
+
|
290
|
+
Background versions of these models are prefixed with `bg` and the first level of the module capitalized (e.g. `keyword` for foreground colors and `bgKeyword` for background colors).
|
291
|
+
|
292
|
+
- `chalk.bgHex('#DEADED').underline('Hello, world!')`
|
293
|
+
- `chalk.bgKeyword('orange')('Some orange text')`
|
294
|
+
- `chalk.bgRgb(15, 100, 204).inverse('Hello!')`
|
295
|
+
|
296
|
+
The following color models can be used:
|
297
|
+
|
298
|
+
- [`rgb`](https://en.wikipedia.org/wiki/RGB_color_model) - Example: `chalk.rgb(255, 136, 0).bold('Orange!')`
|
299
|
+
- [`hex`](https://en.wikipedia.org/wiki/Web_colors#Hex_triplet) - Example: `chalk.hex('#FF8800').bold('Orange!')`
|
300
|
+
- [`keyword`](https://www.w3.org/wiki/CSS/Properties/color/keywords) (CSS keywords) - Example: `chalk.keyword('orange').bold('Orange!')`
|
301
|
+
- [`hsl`](https://en.wikipedia.org/wiki/HSL_and_HSV) - Example: `chalk.hsl(32, 100, 50).bold('Orange!')`
|
302
|
+
- [`hsv`](https://en.wikipedia.org/wiki/HSL_and_HSV) - Example: `chalk.hsv(32, 100, 100).bold('Orange!')`
|
303
|
+
- [`hwb`](https://en.wikipedia.org/wiki/HWB_color_model) - Example: `chalk.hwb(32, 0, 50).bold('Orange!')`
|
304
|
+
- [`ansi`](https://en.wikipedia.org/wiki/ANSI_escape_code#3/4_bit) - Example: `chalk.ansi(31).bgAnsi(93)('red on yellowBright')`
|
305
|
+
- [`ansi256`](https://en.wikipedia.org/wiki/ANSI_escape_code#8-bit) - Example: `chalk.bgAnsi256(194)('Honeydew, more or less')`
|
306
|
+
|
307
|
+
## Windows
|
308
|
+
|
309
|
+
If you're on Windows, do yourself a favor and use [Windows Terminal](https://github.com/microsoft/terminal) instead of `cmd.exe`.
|
310
|
+
|
311
|
+
## Origin story
|
312
|
+
|
313
|
+
[colors.js](https://github.com/Marak/colors.js) used to be the most popular string styling module, but it has serious deficiencies like extending `String.prototype` which causes all kinds of [problems](https://github.com/yeoman/yo/issues/68) and the package is unmaintained. Although there are other packages, they either do too much or not enough. Chalk is a clean and focused alternative.
|
314
|
+
|
315
|
+
## chalk for enterprise
|
316
|
+
|
317
|
+
Available as part of the Tidelift Subscription.
|
318
|
+
|
319
|
+
The maintainers of chalk and thousands of other packages are working with Tidelift to deliver commercial support and maintenance for the open source dependencies you use to build your applications. Save time, reduce risk, and improve code health, while paying the maintainers of the exact dependencies you use. [Learn more.](https://tidelift.com/subscription/pkg/npm-chalk?utm_source=npm-chalk&utm_medium=referral&utm_campaign=enterprise&utm_term=repo)
|
320
|
+
|
321
|
+
## Related
|
322
|
+
|
323
|
+
- [chalk-cli](https://github.com/chalk/chalk-cli) - CLI for this module
|
324
|
+
- [ansi-styles](https://github.com/chalk/ansi-styles) - ANSI escape codes for styling strings in the terminal
|
325
|
+
- [supports-color](https://github.com/chalk/supports-color) - Detect whether a terminal supports color
|
326
|
+
- [strip-ansi](https://github.com/chalk/strip-ansi) - Strip ANSI escape codes
|
327
|
+
- [strip-ansi-stream](https://github.com/chalk/strip-ansi-stream) - Strip ANSI escape codes from a stream
|
328
|
+
- [has-ansi](https://github.com/chalk/has-ansi) - Check if a string has ANSI escape codes
|
329
|
+
- [ansi-regex](https://github.com/chalk/ansi-regex) - Regular expression for matching ANSI escape codes
|
330
|
+
- [wrap-ansi](https://github.com/chalk/wrap-ansi) - Wordwrap a string with ANSI escape codes
|
331
|
+
- [slice-ansi](https://github.com/chalk/slice-ansi) - Slice a string with ANSI escape codes
|
332
|
+
- [color-convert](https://github.com/qix-/color-convert) - Converts colors between different models
|
333
|
+
- [chalk-animation](https://github.com/bokub/chalk-animation) - Animate strings in the terminal
|
334
|
+
- [gradient-string](https://github.com/bokub/gradient-string) - Apply color gradients to strings
|
335
|
+
- [chalk-pipe](https://github.com/LitoMore/chalk-pipe) - Create chalk style schemes with simpler style strings
|
336
|
+
- [terminal-link](https://github.com/sindresorhus/terminal-link) - Create clickable links in the terminal
|
337
|
+
|
338
|
+
## Maintainers
|
339
|
+
|
340
|
+
- [Sindre Sorhus](https://github.com/sindresorhus)
|
341
|
+
- [Josh Junon](https://github.com/qix-)
|
@@ -0,0 +1,229 @@
|
|
1
|
+
'use strict';
|
2
|
+
const ansiStyles = require('ansi-styles');
|
3
|
+
const {stdout: stdoutColor, stderr: stderrColor} = require('supports-color');
|
4
|
+
const {
|
5
|
+
stringReplaceAll,
|
6
|
+
stringEncaseCRLFWithFirstIndex
|
7
|
+
} = require('./util');
|
8
|
+
|
9
|
+
const {isArray} = Array;
|
10
|
+
|
11
|
+
// `supportsColor.level` → `ansiStyles.color[name]` mapping
|
12
|
+
const levelMapping = [
|
13
|
+
'ansi',
|
14
|
+
'ansi',
|
15
|
+
'ansi256',
|
16
|
+
'ansi16m'
|
17
|
+
];
|
18
|
+
|
19
|
+
const styles = Object.create(null);
|
20
|
+
|
21
|
+
const applyOptions = (object, options = {}) => {
|
22
|
+
if (options.level && !(Number.isInteger(options.level) && options.level >= 0 && options.level <= 3)) {
|
23
|
+
throw new Error('The `level` option should be an integer from 0 to 3');
|
24
|
+
}
|
25
|
+
|
26
|
+
// Detect level if not set manually
|
27
|
+
const colorLevel = stdoutColor ? stdoutColor.level : 0;
|
28
|
+
object.level = options.level === undefined ? colorLevel : options.level;
|
29
|
+
};
|
30
|
+
|
31
|
+
class ChalkClass {
|
32
|
+
constructor(options) {
|
33
|
+
// eslint-disable-next-line no-constructor-return
|
34
|
+
return chalkFactory(options);
|
35
|
+
}
|
36
|
+
}
|
37
|
+
|
38
|
+
const chalkFactory = options => {
|
39
|
+
const chalk = {};
|
40
|
+
applyOptions(chalk, options);
|
41
|
+
|
42
|
+
chalk.template = (...arguments_) => chalkTag(chalk.template, ...arguments_);
|
43
|
+
|
44
|
+
Object.setPrototypeOf(chalk, Chalk.prototype);
|
45
|
+
Object.setPrototypeOf(chalk.template, chalk);
|
46
|
+
|
47
|
+
chalk.template.constructor = () => {
|
48
|
+
throw new Error('`chalk.constructor()` is deprecated. Use `new chalk.Instance()` instead.');
|
49
|
+
};
|
50
|
+
|
51
|
+
chalk.template.Instance = ChalkClass;
|
52
|
+
|
53
|
+
return chalk.template;
|
54
|
+
};
|
55
|
+
|
56
|
+
function Chalk(options) {
|
57
|
+
return chalkFactory(options);
|
58
|
+
}
|
59
|
+
|
60
|
+
for (const [styleName, style] of Object.entries(ansiStyles)) {
|
61
|
+
styles[styleName] = {
|
62
|
+
get() {
|
63
|
+
const builder = createBuilder(this, createStyler(style.open, style.close, this._styler), this._isEmpty);
|
64
|
+
Object.defineProperty(this, styleName, {value: builder});
|
65
|
+
return builder;
|
66
|
+
}
|
67
|
+
};
|
68
|
+
}
|
69
|
+
|
70
|
+
styles.visible = {
|
71
|
+
get() {
|
72
|
+
const builder = createBuilder(this, this._styler, true);
|
73
|
+
Object.defineProperty(this, 'visible', {value: builder});
|
74
|
+
return builder;
|
75
|
+
}
|
76
|
+
};
|
77
|
+
|
78
|
+
const usedModels = ['rgb', 'hex', 'keyword', 'hsl', 'hsv', 'hwb', 'ansi', 'ansi256'];
|
79
|
+
|
80
|
+
for (const model of usedModels) {
|
81
|
+
styles[model] = {
|
82
|
+
get() {
|
83
|
+
const {level} = this;
|
84
|
+
return function (...arguments_) {
|
85
|
+
const styler = createStyler(ansiStyles.color[levelMapping[level]][model](...arguments_), ansiStyles.color.close, this._styler);
|
86
|
+
return createBuilder(this, styler, this._isEmpty);
|
87
|
+
};
|
88
|
+
}
|
89
|
+
};
|
90
|
+
}
|
91
|
+
|
92
|
+
for (const model of usedModels) {
|
93
|
+
const bgModel = 'bg' + model[0].toUpperCase() + model.slice(1);
|
94
|
+
styles[bgModel] = {
|
95
|
+
get() {
|
96
|
+
const {level} = this;
|
97
|
+
return function (...arguments_) {
|
98
|
+
const styler = createStyler(ansiStyles.bgColor[levelMapping[level]][model](...arguments_), ansiStyles.bgColor.close, this._styler);
|
99
|
+
return createBuilder(this, styler, this._isEmpty);
|
100
|
+
};
|
101
|
+
}
|
102
|
+
};
|
103
|
+
}
|
104
|
+
|
105
|
+
const proto = Object.defineProperties(() => {}, {
|
106
|
+
...styles,
|
107
|
+
level: {
|
108
|
+
enumerable: true,
|
109
|
+
get() {
|
110
|
+
return this._generator.level;
|
111
|
+
},
|
112
|
+
set(level) {
|
113
|
+
this._generator.level = level;
|
114
|
+
}
|
115
|
+
}
|
116
|
+
});
|
117
|
+
|
118
|
+
const createStyler = (open, close, parent) => {
|
119
|
+
let openAll;
|
120
|
+
let closeAll;
|
121
|
+
if (parent === undefined) {
|
122
|
+
openAll = open;
|
123
|
+
closeAll = close;
|
124
|
+
} else {
|
125
|
+
openAll = parent.openAll + open;
|
126
|
+
closeAll = close + parent.closeAll;
|
127
|
+
}
|
128
|
+
|
129
|
+
return {
|
130
|
+
open,
|
131
|
+
close,
|
132
|
+
openAll,
|
133
|
+
closeAll,
|
134
|
+
parent
|
135
|
+
};
|
136
|
+
};
|
137
|
+
|
138
|
+
const createBuilder = (self, _styler, _isEmpty) => {
|
139
|
+
const builder = (...arguments_) => {
|
140
|
+
if (isArray(arguments_[0]) && isArray(arguments_[0].raw)) {
|
141
|
+
// Called as a template literal, for example: chalk.red`2 + 3 = {bold ${2+3}}`
|
142
|
+
return applyStyle(builder, chalkTag(builder, ...arguments_));
|
143
|
+
}
|
144
|
+
|
145
|
+
// Single argument is hot path, implicit coercion is faster than anything
|
146
|
+
// eslint-disable-next-line no-implicit-coercion
|
147
|
+
return applyStyle(builder, (arguments_.length === 1) ? ('' + arguments_[0]) : arguments_.join(' '));
|
148
|
+
};
|
149
|
+
|
150
|
+
// We alter the prototype because we must return a function, but there is
|
151
|
+
// no way to create a function with a different prototype
|
152
|
+
Object.setPrototypeOf(builder, proto);
|
153
|
+
|
154
|
+
builder._generator = self;
|
155
|
+
builder._styler = _styler;
|
156
|
+
builder._isEmpty = _isEmpty;
|
157
|
+
|
158
|
+
return builder;
|
159
|
+
};
|
160
|
+
|
161
|
+
const applyStyle = (self, string) => {
|
162
|
+
if (self.level <= 0 || !string) {
|
163
|
+
return self._isEmpty ? '' : string;
|
164
|
+
}
|
165
|
+
|
166
|
+
let styler = self._styler;
|
167
|
+
|
168
|
+
if (styler === undefined) {
|
169
|
+
return string;
|
170
|
+
}
|
171
|
+
|
172
|
+
const {openAll, closeAll} = styler;
|
173
|
+
if (string.indexOf('\u001B') !== -1) {
|
174
|
+
while (styler !== undefined) {
|
175
|
+
// Replace any instances already present with a re-opening code
|
176
|
+
// otherwise only the part of the string until said closing code
|
177
|
+
// will be colored, and the rest will simply be 'plain'.
|
178
|
+
string = stringReplaceAll(string, styler.close, styler.open);
|
179
|
+
|
180
|
+
styler = styler.parent;
|
181
|
+
}
|
182
|
+
}
|
183
|
+
|
184
|
+
// We can move both next actions out of loop, because remaining actions in loop won't have
|
185
|
+
// any/visible effect on parts we add here. Close the styling before a linebreak and reopen
|
186
|
+
// after next line to fix a bleed issue on macOS: https://github.com/chalk/chalk/pull/92
|
187
|
+
const lfIndex = string.indexOf('\n');
|
188
|
+
if (lfIndex !== -1) {
|
189
|
+
string = stringEncaseCRLFWithFirstIndex(string, closeAll, openAll, lfIndex);
|
190
|
+
}
|
191
|
+
|
192
|
+
return openAll + string + closeAll;
|
193
|
+
};
|
194
|
+
|
195
|
+
let template;
|
196
|
+
const chalkTag = (chalk, ...strings) => {
|
197
|
+
const [firstString] = strings;
|
198
|
+
|
199
|
+
if (!isArray(firstString) || !isArray(firstString.raw)) {
|
200
|
+
// If chalk() was called by itself or with a string,
|
201
|
+
// return the string itself as a string.
|
202
|
+
return strings.join(' ');
|
203
|
+
}
|
204
|
+
|
205
|
+
const arguments_ = strings.slice(1);
|
206
|
+
const parts = [firstString.raw[0]];
|
207
|
+
|
208
|
+
for (let i = 1; i < firstString.length; i++) {
|
209
|
+
parts.push(
|
210
|
+
String(arguments_[i - 1]).replace(/[{}\\]/g, '\\$&'),
|
211
|
+
String(firstString.raw[i])
|
212
|
+
);
|
213
|
+
}
|
214
|
+
|
215
|
+
if (template === undefined) {
|
216
|
+
template = require('./templates');
|
217
|
+
}
|
218
|
+
|
219
|
+
return template(chalk, parts.join(''));
|
220
|
+
};
|
221
|
+
|
222
|
+
Object.defineProperties(Chalk.prototype, styles);
|
223
|
+
|
224
|
+
const chalk = Chalk(); // eslint-disable-line new-cap
|
225
|
+
chalk.supportsColor = stdoutColor;
|
226
|
+
chalk.stderr = Chalk({level: stderrColor ? stderrColor.level : 0}); // eslint-disable-line new-cap
|
227
|
+
chalk.stderr.supportsColor = stderrColor;
|
228
|
+
|
229
|
+
module.exports = chalk;
|
@@ -0,0 +1,134 @@
|
|
1
|
+
'use strict';
|
2
|
+
const TEMPLATE_REGEX = /(?:\\(u(?:[a-f\d]{4}|\{[a-f\d]{1,6}\})|x[a-f\d]{2}|.))|(?:\{(~)?(\w+(?:\([^)]*\))?(?:\.\w+(?:\([^)]*\))?)*)(?:[ \t]|(?=\r?\n)))|(\})|((?:.|[\r\n\f])+?)/gi;
|
3
|
+
const STYLE_REGEX = /(?:^|\.)(\w+)(?:\(([^)]*)\))?/g;
|
4
|
+
const STRING_REGEX = /^(['"])((?:\\.|(?!\1)[^\\])*)\1$/;
|
5
|
+
const ESCAPE_REGEX = /\\(u(?:[a-f\d]{4}|{[a-f\d]{1,6}})|x[a-f\d]{2}|.)|([^\\])/gi;
|
6
|
+
|
7
|
+
const ESCAPES = new Map([
|
8
|
+
['n', '\n'],
|
9
|
+
['r', '\r'],
|
10
|
+
['t', '\t'],
|
11
|
+
['b', '\b'],
|
12
|
+
['f', '\f'],
|
13
|
+
['v', '\v'],
|
14
|
+
['0', '\0'],
|
15
|
+
['\\', '\\'],
|
16
|
+
['e', '\u001B'],
|
17
|
+
['a', '\u0007']
|
18
|
+
]);
|
19
|
+
|
20
|
+
function unescape(c) {
|
21
|
+
const u = c[0] === 'u';
|
22
|
+
const bracket = c[1] === '{';
|
23
|
+
|
24
|
+
if ((u && !bracket && c.length === 5) || (c[0] === 'x' && c.length === 3)) {
|
25
|
+
return String.fromCharCode(parseInt(c.slice(1), 16));
|
26
|
+
}
|
27
|
+
|
28
|
+
if (u && bracket) {
|
29
|
+
return String.fromCodePoint(parseInt(c.slice(2, -1), 16));
|
30
|
+
}
|
31
|
+
|
32
|
+
return ESCAPES.get(c) || c;
|
33
|
+
}
|
34
|
+
|
35
|
+
function parseArguments(name, arguments_) {
|
36
|
+
const results = [];
|
37
|
+
const chunks = arguments_.trim().split(/\s*,\s*/g);
|
38
|
+
let matches;
|
39
|
+
|
40
|
+
for (const chunk of chunks) {
|
41
|
+
const number = Number(chunk);
|
42
|
+
if (!Number.isNaN(number)) {
|
43
|
+
results.push(number);
|
44
|
+
} else if ((matches = chunk.match(STRING_REGEX))) {
|
45
|
+
results.push(matches[2].replace(ESCAPE_REGEX, (m, escape, character) => escape ? unescape(escape) : character));
|
46
|
+
} else {
|
47
|
+
throw new Error(`Invalid Chalk template style argument: ${chunk} (in style '${name}')`);
|
48
|
+
}
|
49
|
+
}
|
50
|
+
|
51
|
+
return results;
|
52
|
+
}
|
53
|
+
|
54
|
+
function parseStyle(style) {
|
55
|
+
STYLE_REGEX.lastIndex = 0;
|
56
|
+
|
57
|
+
const results = [];
|
58
|
+
let matches;
|
59
|
+
|
60
|
+
while ((matches = STYLE_REGEX.exec(style)) !== null) {
|
61
|
+
const name = matches[1];
|
62
|
+
|
63
|
+
if (matches[2]) {
|
64
|
+
const args = parseArguments(name, matches[2]);
|
65
|
+
results.push([name].concat(args));
|
66
|
+
} else {
|
67
|
+
results.push([name]);
|
68
|
+
}
|
69
|
+
}
|
70
|
+
|
71
|
+
return results;
|
72
|
+
}
|
73
|
+
|
74
|
+
function buildStyle(chalk, styles) {
|
75
|
+
const enabled = {};
|
76
|
+
|
77
|
+
for (const layer of styles) {
|
78
|
+
for (const style of layer.styles) {
|
79
|
+
enabled[style[0]] = layer.inverse ? null : style.slice(1);
|
80
|
+
}
|
81
|
+
}
|
82
|
+
|
83
|
+
let current = chalk;
|
84
|
+
for (const [styleName, styles] of Object.entries(enabled)) {
|
85
|
+
if (!Array.isArray(styles)) {
|
86
|
+
continue;
|
87
|
+
}
|
88
|
+
|
89
|
+
if (!(styleName in current)) {
|
90
|
+
throw new Error(`Unknown Chalk style: ${styleName}`);
|
91
|
+
}
|
92
|
+
|
93
|
+
current = styles.length > 0 ? current[styleName](...styles) : current[styleName];
|
94
|
+
}
|
95
|
+
|
96
|
+
return current;
|
97
|
+
}
|
98
|
+
|
99
|
+
module.exports = (chalk, temporary) => {
|
100
|
+
const styles = [];
|
101
|
+
const chunks = [];
|
102
|
+
let chunk = [];
|
103
|
+
|
104
|
+
// eslint-disable-next-line max-params
|
105
|
+
temporary.replace(TEMPLATE_REGEX, (m, escapeCharacter, inverse, style, close, character) => {
|
106
|
+
if (escapeCharacter) {
|
107
|
+
chunk.push(unescape(escapeCharacter));
|
108
|
+
} else if (style) {
|
109
|
+
const string = chunk.join('');
|
110
|
+
chunk = [];
|
111
|
+
chunks.push(styles.length === 0 ? string : buildStyle(chalk, styles)(string));
|
112
|
+
styles.push({inverse, styles: parseStyle(style)});
|
113
|
+
} else if (close) {
|
114
|
+
if (styles.length === 0) {
|
115
|
+
throw new Error('Found extraneous } in Chalk template literal');
|
116
|
+
}
|
117
|
+
|
118
|
+
chunks.push(buildStyle(chalk, styles)(chunk.join('')));
|
119
|
+
chunk = [];
|
120
|
+
styles.pop();
|
121
|
+
} else {
|
122
|
+
chunk.push(character);
|
123
|
+
}
|
124
|
+
});
|
125
|
+
|
126
|
+
chunks.push(chunk.join(''));
|
127
|
+
|
128
|
+
if (styles.length > 0) {
|
129
|
+
const errMessage = `Chalk template literal is missing ${styles.length} closing bracket${styles.length === 1 ? '' : 's'} (\`}\`)`;
|
130
|
+
throw new Error(errMessage);
|
131
|
+
}
|
132
|
+
|
133
|
+
return chunks.join('');
|
134
|
+
};
|