tools: Enable color in shellcheck.

This commit is contained in:
Andrew Hamilton 2019-07-20 14:21:26 +10:00
parent 4a1e109f07
commit 975737d71d
4 changed files with 8 additions and 3 deletions

View file

@ -11,7 +11,7 @@ import sys
ESC = "\x1b"
normal = "[m"
normal = "[m" # or "[0m"
bold = "[1m"
italic = "[3m"
standout = "[7m"

View file

@ -170,7 +170,7 @@ class TermStr(collections.UserString):
end_index = part.index("m")
except ValueError:
end_index = 0
if part[:2] == "[m": # Normal
if part[:2] == terminal.normal or part[:3] == "[0m": # Normal
is_bold, is_italic, is_underlined = False, False, False
fg_color, bg_color = None, None
elif part[:3] == terminal.bold:

View file

@ -220,7 +220,8 @@ tools_for_extensions = [
[shellcheck]
dependencies = ["shellcheck"]
command = "shellcheck"
command = "shellcheck --color=always"
has_color = true
[cppcheck]
dependencies = ["cppcheck"]

View file

@ -144,6 +144,10 @@ class TermStrTests(unittest.TestCase):
eris.terminal.ESC + "[mbar"),
termstr.TermStr("foo").bg_color(5) +
termstr.TermStr("bar"))
self.assertEqual(TermStr.from_term(eris.terminal.ESC + "[45mfoo" +
eris.terminal.ESC + "[0mbar"),
termstr.TermStr("foo").bg_color(5) +
termstr.TermStr("bar"))
if __name__ == "__main__":