-
-
Notifications
You must be signed in to change notification settings - Fork 10
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
Conversation
There was a problem hiding this 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();
});
There was a problem hiding this 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 🙂
🎉 This PR is included in version 2.1.0 🎉 The release is available on: Your semantic-release bot 📦🚀 |
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
todumb
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