Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

yamprint with colors should extends util.inspect #1

Open
patarapolw opened this issue Feb 25, 2020 · 0 comments
Open

yamprint with colors should extends util.inspect #1

patarapolw opened this issue Feb 25, 2020 · 0 comments

Comments

@patarapolw
Copy link

patarapolw commented Feb 25, 2020

Instead of using your own yamprint-ansi-color, there is already util.inspect.styles.

So, the easiest way to get colors is

import { inspect } from 'util'

import { yamprint, YamprintTheme } from 'yamprint'
import chalk from 'chalk'

const yp = yamprint.extend({
  formatter: Object.entries(inspect.styles).reduce((prev, [k, v]) => ({
    ...prev,
    [k]: (chalk as any)[v]
  }), {
    lineInMultilineBlock: (chalk as any)[inspect.styles.string]
  } as YamprintTheme)
})

But, I just couldn't avoid chalk as a dependency...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant