(stream: NodeJS.WritableStream = process.stdout)
| 11 | export { color as colors, figures } from 'listr2'; |
| 12 | |
| 13 | export function supportColor(stream: NodeJS.WritableStream = process.stdout): boolean { |
| 14 | if (stream instanceof WriteStream) { |
| 15 | return stream.hasColors(); |
| 16 | } |
| 17 | |
| 18 | try { |
| 19 | // The hasColors function does not rely on any instance state and should ideally be static |
| 20 | return WriteStream.prototype.hasColors(); |
| 21 | } catch { |
| 22 | return process.env['FORCE_COLOR'] !== undefined && process.env['FORCE_COLOR'] !== '0'; |
| 23 | } |
| 24 | } |