Skip to content

Comments

Use picocolors instead of supports-color#5509

Closed
sdotson wants to merge 1 commit intomochajs:mainfrom
sdotson:use-picocolors-instead-of-supports-color
Closed

Use picocolors instead of supports-color#5509
sdotson wants to merge 1 commit intomochajs:mainfrom
sdotson:use-picocolors-instead-of-supports-color

Conversation

@sdotson
Copy link

@sdotson sdotson commented Oct 21, 2025

PR Checklist

Overview

Summary

Removes the supports-color dependency in favor of using picocolors' built-in isColorSupported property, which provides the same functionality.

Changes

  • Replaced require('supports-color') with require('picocolors') in lib/reporters/base.js
  • Updated color detection logic from supportsColor.stdout to pc.isColorSupported
  • Removed supports-color from production dependencies in package.json
  • Removed browser shim for supports-color from package.json browser field

Motivation

This change reduces unnecessary dependencies by leveraging functionality already available in picocolors, which Mocha already depends on. The isColorSupported property from picocolors provides the
same color detection capability as supports-color, making the separate dependency redundant.

Fixes #5470

@valadaptive
Copy link
Contributor

I already have a PR for this (though I forgot to remove the browser shim from package.json). It's blocked on alexeyraspopov/picocolors#96, which is causing some tests to fail.

Moved supports-color to dev dependencies in package-lock.json (still used by some dev dependencies)

I noticed this is in your PR summary but not in the code changes itself. That's good because it's not necessary: if a dependency itself depends on a package, it'll get installed anyway--that's how package managers work. Why is this line in the PR summary?

@sdotson
Copy link
Author

sdotson commented Oct 21, 2025

I already have a PR for this (though I forgot to remove the browser shim from package.json). It's blocked on alexeyraspopov/picocolors#96, which is causing some tests to fail.

Moved supports-color to dev dependencies in package-lock.json (still used by some dev dependencies)

I noticed this is in your PR summary but not in the code changes itself. That's good because it's not necessary: if a dependency itself depends on a package, it'll get installed anyway--that's how package managers work. Why is this line in the PR summary?

Oh you're right. My mistake. That line is totally unnecessary. Feel free to close this pr if it is a duplicate.

@JoshuaKGoldberg
Copy link
Member

Thanks for trying this out either way!

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

Successfully merging this pull request may close these issues.

🚀 Feature: Remove supports-color now that we have picocolors

3 participants