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

fix: ensure supportsColor.level exists before stringifying it #901

Merged
merged 4 commits into from Aug 25, 2020

Conversation

iiroj
Copy link
Member

@iiroj iiroj commented Jul 28, 2020

When supports-color detects a level of 0, it will not return an object containing the key level, but instead only false. This commit makes sure supportsColor.level exists before calling supportsColor.level.toString().

The TypeScript definitions of chalk seem wrong in this regard, since they imply that if supportsColor is truthy, it is an object and always contains the level key of type 0 | 1 | 2 | 3.

When supports-color detects a level of 0, it will not return an object containing the key `level`, but instead only `false`. This commit makes sure `supportsColor.level` exists before calling `supportsColor.level.toString()`.

The TypeScript definitions of `chalk` seem wrong in this regard, since they imply that if `supportsColor` is truthy, it is an object and always contains the `level` key of type `0 | 1 | 2 | 3`.
@iiroj iiroj linked an issue Jul 28, 2020 that may be closed by this pull request
@codecov
Copy link

codecov bot commented Aug 24, 2020

Codecov Report

Merging #901 into master will not change coverage.
The diff coverage is n/a.

Impacted file tree graph

@@            Coverage Diff            @@
##            master      #901   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files           17        17           
  Lines          602       602           
  Branches       142       142           
=========================================
  Hits           602       602           
Impacted Files Coverage Δ
lib/gitWorkflow.js 100.00% <ø> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 86c9ed2...7a5182b. Read the comment docs.

@iiroj
Copy link
Member Author

iiroj commented Aug 25, 2020

Ping @okonet can you check this out?

@iiroj iiroj merged commit 10b3218 into master Aug 25, 2020
@iiroj iiroj deleted the fix-supports-color branch August 25, 2020 10:52
@github-actions
Copy link
Contributor

🎉 This PR is included in version 10.2.12 🎉

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
2 participants