chalk/supports-color

supportsColor() should recheck process.env.FORCE_COLOR #114

jaydenseric posted onGitHub

At the moment, the supportsColor() function does not consider all the environment variables fresh each time it's called. This means changing process.env.FORCE_COLOR at runtime has no effect on the supportsColor() result.

This bug prevents us from being able to do process.env.FORCE_COLOR = '1', run a snapshot test of something that uses chalk/supports-color for formatting, then revert the FORCE_COLOR back again.

This issue probably blocks a fix for https://github.com/babel/babel/issues/12442 .


Are you setting that variable prior to including any modules that use supports-color? Or after?

There's always just calling supportsColor.supportsColor(process.stdout) again. That doesn't cache.

EDIT: Oh I see, we do cache that one. Agreed, we shouldn't be doing that.

posted by Qix- over 4 years ago

PR welcome to fix this.

posted by sindresorhus over 4 years ago

Fund this Issue

$0.00
Funded

Pull requests