Skip to content

Commit 672d9dc

Browse files
committed
main: add FORCE_COLOR
Signed-off-by: Filipe Laíns <lains@riseup.net>
1 parent dfa7b6f commit 672d9dc

File tree

3 files changed

+4
-4
lines changed

3 files changed

+4
-4
lines changed

CHANGELOG.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ Unreleased
88

99
- Improved output (`PR #333`_, Fixes `#142`_)
1010
- The CLI now honnors `NO_COLOR`_ (`PR #333`_)
11+
- The CLI can now be forced to colorize the output by setting the ``FORCE_COLOR`` environment variable (`PR #335`_)
1112
- Added logging to ``build`` and ``build.env`` (`PR #333`_)
1213

1314

@@ -17,6 +18,7 @@ Breaking Changes
1718
- Dropped support for Python 2 and 3.5.
1819

1920
.. _PR #333: https://github.com/pypa/build/pull/333
21+
.. _PR #335: https://github.com/pypa/build/pull/335
2022
.. _#142: https://github.com/pypa/build/issues/142
2123
.. _NO_COLOR: https://no-color.org
2224

src/build/__main__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
'underline': '\33[4m',
3434
'reset': '\33[0m',
3535
}
36-
if not sys.stdout.isatty() or 'NO_COLOR' in os.environ:
36+
if 'FORCE_COLOR' not in os.environ and not sys.stdout.isatty() or 'NO_COLOR' in os.environ:
3737
_STYLES = {color: '' for color in _STYLES}
3838

3939

tests/test_main.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -338,9 +338,7 @@ def test_output_env_subprocess_error(
338338
stdout_body,
339339
stdout_error,
340340
):
341-
mocker.patch('sys.stdout.isatty', return_value=True)
342-
if not color:
343-
monkeypatch.setenv('NO_COLOR', '')
341+
monkeypatch.setenv('FORCE_COLOR' if color else 'NO_COLOR', '')
344342

345343
importlib.reload(build.__main__) # reload module to set _STYLES
346344

0 commit comments

Comments
 (0)