mirror of
https://github.com/pre-commit/pre-commit.git
synced 2026-02-17 08:14:42 +04:00
Don't crash when an executable is not found
This commit is contained in:
parent
da7e85c851
commit
5a6b6e81e9
5 changed files with 37 additions and 13 deletions
|
|
@ -12,6 +12,10 @@ from pre_commit import five
|
|||
printable = frozenset(string.printable)
|
||||
|
||||
|
||||
class ExecutableNotFoundError(OSError):
|
||||
pass
|
||||
|
||||
|
||||
def parse_bytesio(bytesio):
|
||||
"""Parse the shebang from a file opened for reading binary."""
|
||||
if bytesio.read(2) != b'#!':
|
||||
|
|
@ -70,7 +74,9 @@ def normexe(orig_exe):
|
|||
if os.sep not in orig_exe:
|
||||
exe = find_executable(orig_exe)
|
||||
if exe is None:
|
||||
raise OSError('Executable {0} not found'.format(orig_exe))
|
||||
raise ExecutableNotFoundError(
|
||||
'Executable `{0}` not found'.format(orig_exe),
|
||||
)
|
||||
return exe
|
||||
else:
|
||||
return orig_exe
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue