-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: change/simplify
hasColors
implementation
It is now a constant, not a function. Dependency-free detection. Credit to sindresorhus/yoctocolors#5
- Loading branch information
1 parent
760fab6
commit 13f32d1
Showing
5 changed files
with
621 additions
and
637 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,5 +8,5 @@ test('colors', () => { | |
}) | ||
|
||
test('hasColors', () => { | ||
console.log(hasColors()) | ||
console.log(hasColors) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,8 @@ | ||
const supporsColorLib = require('supports-color') | ||
import * as tty from 'tty' | ||
|
||
export function hasColors(): boolean { | ||
if (process.env['NO_COLOR']) return false // https://no-color.org/ | ||
return !!supporsColorLib.stdout | ||
} | ||
/** | ||
* Based on: https://github.com/sindresorhus/yoctocolors/pull/5 | ||
* | ||
* @experimental | ||
*/ | ||
export const hasColors = !process.env['NO_COLOR'] && tty.WriteStream.prototype.hasColors() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.