Skip to content

Commit 094ce53

Browse files
committed
add: option to return non-zero if files are changed
1 parent 499b47a commit 094ce53

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

src/mdformat/_cli.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,8 @@ def run(cli_args: Sequence[str], cache_toml: bool = True) -> int: # noqa: C901
178178
return 1
179179
if path:
180180
if formatted_str != original_str:
181+
if opts["exit_non_zero_on_format"]:
182+
format_errors_found = True
181183
path.write_bytes(formatted_str.encode())
182184
else:
183185
sys.stdout.buffer.write(formatted_str.encode())
@@ -210,6 +212,11 @@ def make_arg_parser(
210212
parser.add_argument(
211213
"--check", action="store_true", help="do not apply changes to files"
212214
)
215+
parser.add_argument(
216+
"--exit-non-zero-on-format",
217+
action="store_true",
218+
help="return non-zero if files are modified",
219+
)
213220
parser.add_argument(
214221
"--no-validate",
215222
action="store_const",

0 commit comments

Comments
 (0)