mirror of
https://github.com/pre-commit/pre-commit.git
synced 2026-04-16 10:31:46 +04:00
POC or MVP: Succeeds checking shfmt on Windows which uses bash. Requires that bash is meaningful (WSL, MSys64) on the command prompt, and shfmt is installed in the bash environment.
This commit is contained in:
parent
023b337ff0
commit
e7698cdb38
4 changed files with 102 additions and 2 deletions
|
|
@ -4,6 +4,9 @@ from __future__ import unicode_literals
|
|||
import os.path
|
||||
|
||||
from identify.identify import parse_shebang_from_file
|
||||
from identify.identify import tags_from_path
|
||||
|
||||
from pre_commit import ShelPathConv
|
||||
|
||||
|
||||
class ExecutableNotFoundError(OSError):
|
||||
|
|
@ -71,10 +74,12 @@ def normalize_cmd(cmd):
|
|||
# Use PATH to determine the executable
|
||||
exe = normexe(cmd[0])
|
||||
|
||||
convert = 'shell' in tags_from_path(exe)
|
||||
|
||||
# Figure out the shebang from the resulting command
|
||||
cmd = parse_filename(exe) + (exe,) + cmd[1:]
|
||||
|
||||
# This could have given us back another bare executable
|
||||
exe = normexe(cmd[0])
|
||||
|
||||
return (exe,) + cmd[1:]
|
||||
cmd = (exe,) + cmd[1:]
|
||||
return ShelPathConv.ConvertArgs(*cmd) if convert else cmd
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue