Skip to content

Commit 16b6da5

Browse files
committed
Fixed the propagation of the 'apio format' exit error code.
1 parent dce1d91 commit 16b6da5

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

apio/commands/apio_format.py

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
from typing import Tuple, List, Optional
1515
import click
1616
from apio.common.apio_console import cout, cerror, cstyle
17-
from apio.common.apio_styles import EMPH3, SUCCESS, INFO
17+
from apio.common.apio_styles import EMPH3, SUCCESS, INFO, ERROR
1818
from apio.common.common_util import PROJECT_BUILD_PATH, sort_files
1919
from apio.apio_context import (
2020
ApioContext,
@@ -136,6 +136,7 @@ def cli(
136136
# -- Iterate the files and format one at a time. We could format
137137
# -- all of them at once but this way we can make the output more
138138
# -- user friendly.
139+
failures = 0
139140
for f in files:
140141
# -- Convert to a Path object.
141142
path = Path(f)
@@ -168,7 +169,16 @@ def cli(
168169
exit_code = os.system(command)
169170
if exit_code != 0:
170171
cerror(f"Formatting of '{f}' failed")
171-
return exit_code
172+
failures += 1
173+
174+
# -- Report failures, if eny.
175+
if failures:
176+
cout()
177+
cout(
178+
f"Encountered {util.plurality(failures, 'failure')}.",
179+
style=ERROR,
180+
)
181+
sys.exit(1)
172182

173183
# -- All done ok.
174184
cout(f"Processed {util.plurality(files, 'file')}.", style=SUCCESS)

0 commit comments

Comments
 (0)