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

Allow to disable color in output #53

Merged
merged 3 commits into from
Jan 15, 2022

Conversation

mondeja
Copy link
Member

@mondeja mondeja commented Jan 14, 2022

By setting the environment variables:

  • NO_COLOR
  • SVGLINT_NO_COLOR

And all the checks done by supports-color, like terminal is not a TTY, setting the environment variable TERM to dumb value, passing --no-color command line option... These are all included in latest version of chalk (v5) by default. This version is only compatible with Node>=12.20, so it is in line with SVGLint support.

I've not included a check for color option in config file, let me know if it is really desired, I think that it would add too much regardless complexity.

Closes #50

@ericcornelissen ericcornelissen added enhancement dependencies Pull requests that update a dependency file labels Jan 14, 2022
Copy link
Contributor

@ericcornelissen ericcornelissen left a comment

Choose a reason for hiding this comment

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

Looks good in general @mondeja, nice work! I have two minor comments below.

Also, I was wondering if we can add tests for this in the CLI suite, I came up with the following example tests (you need to add an import for ansi-regex yourself) - ideally we have a test for each method to disable colors. However, the latter seems to be failing on my machine 🤔:

it("has colored output by default", async function(){
    const svg = "./test/svgs/elm.test.svg";
    const { stdout } = await execCliWith([svg]);
    expect(ansiRegex().test(stdout)).toBeTruthy();
});

it("has no colors in output with the --no-color flag", async function(){
    const svg = "./test/svgs/elm.test.svg";
    const { stdout } = await execCliWith([svg, "--no-colors"]);
    expect(ansiRegex().test(stdout)).toBeFalsy();
});

src/lib/logger.js Outdated Show resolved Hide resolved
src/lib/logger.js Outdated Show resolved Hide resolved
Copy link
Contributor

@ericcornelissen ericcornelissen left a comment

Choose a reason for hiding this comment

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

Also, I was wondering if we can add tests for this in the CLI suite, I came up with the following example tests (you need to add an import for ansi-regex yourself) - ideally we have a test for each method to disable colors. However, the latter seems to be failing on my machine 🤔:

I tested this further and it seems that if you run the command as a child process of the test suite, then colors are never supported. Hence, it would be difficult to test this effectively in that test suite.

I've not included a check for color option in config file, let me know if it is really desired, I think that it would add too much regardless complexity.

I agree, if anyone disagrees with this decision in the future, feel free to propose adding it in a new issue/Pull Request with a motivation for why you think it is necessary 🙂

@ericcornelissen ericcornelissen merged commit a8a1b78 into simple-icons:master Jan 15, 2022
@github-actions
Copy link

🎉 This PR is included in version 2.1.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
dependencies Pull requests that update a dependency file enhancement released
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Allow to disable color in output
2 participants