summaryrefslogtreecommitdiffstats
path: root/pre_commit_hooks/file_contents_sorter.py
diff options
context:
space:
mode:
Diffstat (limited to 'pre_commit_hooks/file_contents_sorter.py')
-rw-r--r--pre_commit_hooks/file_contents_sorter.py5
1 files changed, 4 insertions, 1 deletions
diff --git a/pre_commit_hooks/file_contents_sorter.py b/pre_commit_hooks/file_contents_sorter.py
index c5691f0..02bdbcc 100644
--- a/pre_commit_hooks/file_contents_sorter.py
+++ b/pre_commit_hooks/file_contents_sorter.py
@@ -37,7 +37,10 @@ def sort_file_contents(
after = sorted(lines, key=key)
before_string = b''.join(before)
- after_string = b'\n'.join(after) + b'\n'
+ after_string = b'\n'.join(after)
+
+ if after_string:
+ after_string += b'\n'
if before_string == after_string:
return PASS