mirror of
https://github.com/pre-commit/pre-commit-hooks.git
synced 2026-04-05 11:36:54 +00:00
Merge pull request #32 from pre-commit/windows_support
Fix end-of-file-fixer on windows
This commit is contained in:
commit
e39cfdf454
1 changed files with 2 additions and 0 deletions
|
|
@ -16,6 +16,8 @@ def fix_file(file_obj):
|
||||||
last_character = file_obj.read(1)
|
last_character = file_obj.read(1)
|
||||||
# last_character will be '' for an empty file
|
# last_character will be '' for an empty file
|
||||||
if last_character != b'\n' and last_character != b'':
|
if last_character != b'\n' and last_character != b'':
|
||||||
|
# Needs this seek for windows, otherwise IOError
|
||||||
|
file_obj.seek(0, os.SEEK_END)
|
||||||
file_obj.write(b'\n')
|
file_obj.write(b'\n')
|
||||||
return 1
|
return 1
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue