azure-dev
azure-dev copied to clipboard
Make text formatting less fragile on Windows
Currently, to format text, we need to both:
- Add styling around text that requires formatting
- Ensure that any print that consumes the formatted text uses
printWithStyling. Otherwise, it does not work on Windows.
We want a solution that ensures we support other Windows 10 and up users, while providing a reasonable experience on older Windows versions:
- Enable
ENABLE_VIRTUAL_TERMINAL_PROCESSINGby default. We can check the return code to see if the feature isn't supported for the particular version of Windows. - If virtual terminal processing isn't supported, we simply set
color.NoColortotrue, effectively disabling all color output. That way, users do not see escape characters show up in their console, has a reasonable experience, and we also don't eat the cost of maintaining this largely deprecated path.
Originally posted by @weikanglim in https://github.com/Azure/azure-dev/pull/208#discussion_r933603350