Skip to content

Commit

Permalink
Update colorette to enable behaviour consistent with earlier pino-pre…
Browse files Browse the repository at this point in the history
…tty versions (#230)
  • Loading branch information
kibertoad authored Sep 17, 2021
1 parent 32127ed commit 9c26bd4
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 19 deletions.
4 changes: 2 additions & 2 deletions Readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ with keys corresponding to the options described in [CLI Arguments](#cliargs):

```js
{
colorize: colorette.options.enabled, // --colorize
colorize: colorette.isColorSupported, // --colorize
crlf: false, // --crlf
errorLikeObjectKeys: ['err', 'error'], // --errorLikeObjectKeys
errorProps: '', // --errorProps
Expand All @@ -150,7 +150,7 @@ with keys corresponding to the options described in [CLI Arguments](#cliargs):
```

The `colorize` default follows
[`colorette.options.enabled`](https://github.com/jorgebucaran/colorette#optionsenabled).
[`colorette.isColorSupported`](https://github.com/jorgebucaran/colorette#iscolorsupported).

`customPrettifiers` option provides the ability to add a custom prettify function
for specific log properties. `customPrettifiers` is an object, where keys are
Expand Down
4 changes: 2 additions & 2 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
'use strict'

const { options: coloretteOptions } = require('colorette')
const { isColorSupported } = require('colorette')
const pump = require('pump')
const { Transform } = require('readable-stream')
const abstractTransport = require('pino-abstract-transport')
Expand Down Expand Up @@ -29,7 +29,7 @@ const jsonParser = input => {
}

const defaultOptions = {
colorize: coloretteOptions.enabled,
colorize: isColorSupported,
crlf: false,
errorLikeObjectKeys: ERROR_LIKE_KEYS,
errorProps: '',
Expand Down
22 changes: 12 additions & 10 deletions lib/colors.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,19 @@ const plain = {
greyMessage: nocolor
}

const colorette = require('colorette')
const { createColors } = require('colorette')
const { white, bgRed, red, yellow, green, blue, gray, cyan } = createColors({ useColor: true })

const colored = {
default: colorette.white,
60: colorette.bgRed,
50: colorette.red,
40: colorette.yellow,
30: colorette.green,
20: colorette.blue,
10: colorette.gray,
message: colorette.cyan,
greyMessage: colorette.gray
default: white,
60: bgRed,
50: red,
40: yellow,
30: green,
20: blue,
10: gray,
message: cyan,
greyMessage: gray
}

function colorizeLevel (level, colorizer) {
Expand Down
10 changes: 5 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
],
"dependencies": {
"args": "^5.0.1",
"colorette": "^1.3.0",
"colorette": "^2.0.0",
"dateformat": "^4.5.1",
"fast-safe-stringify": "^2.0.7",
"joycon": "^3.0.0",
Expand All @@ -46,15 +46,15 @@
"strip-json-comments": "^3.1.1"
},
"devDependencies": {
"@types/node": "^16.0.0",
"pino": "^6.0.0",
"@types/node": "^16.9.2",
"pino": "^6.13.2",
"pre-commit": "^1.2.2",
"rimraf": "^3.0.2",
"snazzy": "^9.0.0",
"standard": "^16.0.3",
"tap": "^15.0.0",
"tap": "^15.0.9",
"tsd": "^0.17.0",
"typescript": "^4.2.4"
"typescript": "^4.4.3"
},
"tsd": {
"directory": "./test/types"
Expand Down

0 comments on commit 9c26bd4

Please sign in to comment.