Skip to content

Update ansi.luau #160

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

Open
wants to merge 5 commits into
base: primary
Choose a base branch
from
Open

Conversation

ffrostfall
Copy link
Contributor

  • ansi.luau -> colorful.luau
  • NO_COLOR support
  • export Styler type
  • add combine(...), looks like combine(colorful.red, colorful.bold)("This is red bold text!")
  • update to use string interpolation instead of concatenation in some places

Comment on lines 6 to 8
local function colorDisabled(): boolean
-- is it really okay to index env every style call?
return process.env.NO_COLOR ~= nil
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd suggest looking at how picocolors handles NO_COLOR. it also returns a generator function where you can explicitly specify if you want colors or not (but default returns the inferred preference) https://github.com/alexeyraspopov/picocolors/blob/main/picocolors.js

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I think it'd be reasonable to return a function here, e.g.

function(colorsEnabled: boolean?)
    local colorsEnabled = colorsEnabled or (process.env.NO_COLOR ~= nil)

    return ...
end

Co-authored-by: ariel <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

3 participants