lib: support `FORCE_COLOR` for non TTY streams
The current behavior of FORCE_COLOR
is to take effect when stdout
/stderr
are TTY's
according to the documentation:
The FORCE_COLOR environment variable is used to enable ANSI colorized output.
this PR moves the check for the value of FORCE_COLOR
before testing isTTY
- and extracts the logic to a central utility.
Refs: https://github.com/nodejs/node/issues/31409#issuecomment-575938492