mirror of
https://github.com/pre-commit/pre-commit.git
synced 2026-02-17 16:24:40 +04:00
More miscellaneous cleanup
This commit is contained in:
parent
489d9f9926
commit
df40e862f4
33 changed files with 209 additions and 296 deletions
|
|
@ -30,9 +30,9 @@ def get_env_patch(env: str) -> PatchesT:
|
|||
# seems to be used for python.exe.
|
||||
path: SubstitutionT = (os.path.join(env, 'bin'), os.pathsep, Var('PATH'))
|
||||
if os.name == 'nt': # pragma: no cover (platform specific)
|
||||
path = (env, os.pathsep) + path
|
||||
path = (os.path.join(env, 'Scripts'), os.pathsep) + path
|
||||
path = (os.path.join(env, 'Library', 'bin'), os.pathsep) + path
|
||||
path = (env, os.pathsep, *path)
|
||||
path = (os.path.join(env, 'Scripts'), os.pathsep, *path)
|
||||
path = (os.path.join(env, 'Library', 'bin'), os.pathsep, *path)
|
||||
|
||||
return (
|
||||
('PYTHONHOME', UNSET),
|
||||
|
|
|
|||
|
|
@ -18,6 +18,6 @@ def run_hook(
|
|||
file_args: Sequence[str],
|
||||
color: bool,
|
||||
) -> Tuple[int, bytes]:
|
||||
out = hook.entry.encode() + b'\n\n'
|
||||
out = f'{hook.entry}\n\n'.encode()
|
||||
out += b'\n'.join(f.encode() for f in file_args) + b'\n'
|
||||
return 1, out
|
||||
|
|
|
|||
|
|
@ -68,7 +68,7 @@ def install_environment(
|
|||
|
||||
# https://msdn.microsoft.com/en-us/library/windows/desktop/aa365247(v=vs.85).aspx?f=255&MSPPError=-2147217396#maxpath
|
||||
if sys.platform == 'win32': # pragma: no cover
|
||||
envdir = '\\\\?\\' + os.path.normpath(envdir)
|
||||
envdir = f'\\\\?\\{os.path.normpath(envdir)}'
|
||||
with clean_path_on_failure(envdir):
|
||||
cmd = [
|
||||
sys.executable, '-mnodeenv', '--prebuilt', '--clean-src', envdir,
|
||||
|
|
@ -83,7 +83,7 @@ def install_environment(
|
|||
helpers.run_setup_cmd(prefix, ('npm', 'install'))
|
||||
helpers.run_setup_cmd(
|
||||
prefix,
|
||||
('npm', 'install', '-g', '.') + additional_dependencies,
|
||||
('npm', 'install', '-g', '.', *additional_dependencies),
|
||||
)
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -49,9 +49,8 @@ def _find_by_py_launcher(
|
|||
if version.startswith('python'):
|
||||
num = version[len('python'):]
|
||||
try:
|
||||
return cmd_output(
|
||||
'py', f'-{num}', '-c', 'import sys; print(sys.executable)',
|
||||
)[1].strip()
|
||||
cmd = ('py', f'-{num}', '-c', 'import sys; print(sys.executable)')
|
||||
return cmd_output(*cmd)[1].strip()
|
||||
except CalledProcessError:
|
||||
pass
|
||||
return None
|
||||
|
|
|
|||
|
|
@ -109,12 +109,14 @@ def install_environment(
|
|||
# Need to call this after installing to set up the shims
|
||||
helpers.run_setup_cmd(prefix, ('rbenv', 'rehash'))
|
||||
helpers.run_setup_cmd(
|
||||
prefix, ('gem', 'build') + prefix.star('.gemspec'),
|
||||
prefix, ('gem', 'build', *prefix.star('.gemspec')),
|
||||
)
|
||||
helpers.run_setup_cmd(
|
||||
prefix,
|
||||
('gem', 'install', '--no-document') +
|
||||
prefix.star('.gem') + additional_dependencies,
|
||||
(
|
||||
'gem', 'install', '--no-document',
|
||||
*prefix.star('.gem'), *additional_dependencies,
|
||||
),
|
||||
)
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -27,10 +27,7 @@ healthy = helpers.basic_healthy
|
|||
|
||||
def get_env_patch(target_dir: str) -> PatchesT:
|
||||
return (
|
||||
(
|
||||
'PATH',
|
||||
(os.path.join(target_dir, 'bin'), os.pathsep, Var('PATH')),
|
||||
),
|
||||
('PATH', (os.path.join(target_dir, 'bin'), os.pathsep, Var('PATH'))),
|
||||
)
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -18,6 +18,5 @@ def run_hook(
|
|||
file_args: Sequence[str],
|
||||
color: bool,
|
||||
) -> Tuple[int, bytes]:
|
||||
cmd = hook.cmd
|
||||
cmd = (hook.prefix.path(cmd[0]),) + cmd[1:]
|
||||
cmd = (hook.prefix.path(hook.cmd[0]), *hook.cmd[1:])
|
||||
return helpers.run_xargs(hook, cmd, file_args, color=color)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue