mirror of
https://github.com/pre-commit/pre-commit.git
synced 2026-02-19 17:14:43 +04:00
coursier: Add support for both cs and coursier executable names
On some systems, the executable might be named `coursier` instead of `cs`. For example, this is the case on Arch Linux when using the AUR package, or when following the official instructions when installing the JAR-based launcher: https://get-coursier.io/docs/cli-installation#jar-based-launcher
This commit is contained in:
parent
da55e97df8
commit
678ef6b9fd
1 changed files with 10 additions and 1 deletions
|
|
@ -10,6 +10,7 @@ from pre_commit.envcontext import PatchesT
|
||||||
from pre_commit.envcontext import Var
|
from pre_commit.envcontext import Var
|
||||||
from pre_commit.hook import Hook
|
from pre_commit.hook import Hook
|
||||||
from pre_commit.languages import helpers
|
from pre_commit.languages import helpers
|
||||||
|
from pre_commit.parse_shebang import find_executable
|
||||||
from pre_commit.prefix import Prefix
|
from pre_commit.prefix import Prefix
|
||||||
from pre_commit.util import clean_path_on_failure
|
from pre_commit.util import clean_path_on_failure
|
||||||
|
|
||||||
|
|
@ -27,6 +28,14 @@ def install_environment(
|
||||||
helpers.assert_version_default('coursier', version)
|
helpers.assert_version_default('coursier', version)
|
||||||
helpers.assert_no_additional_deps('coursier', additional_dependencies)
|
helpers.assert_no_additional_deps('coursier', additional_dependencies)
|
||||||
|
|
||||||
|
# Support both possible executable names (either "cs" or "coursier")
|
||||||
|
executable = find_executable('cs') or find_executable('coursier')
|
||||||
|
if executable is None:
|
||||||
|
raise AssertionError(
|
||||||
|
'pre-commit requires system-installed "cs" or "coursier" '
|
||||||
|
'executables in the application search path',
|
||||||
|
)
|
||||||
|
|
||||||
envdir = prefix.path(helpers.environment_dir(ENVIRONMENT_DIR, version))
|
envdir = prefix.path(helpers.environment_dir(ENVIRONMENT_DIR, version))
|
||||||
channel = prefix.path('.pre-commit-channel')
|
channel = prefix.path('.pre-commit-channel')
|
||||||
with clean_path_on_failure(envdir):
|
with clean_path_on_failure(envdir):
|
||||||
|
|
@ -36,7 +45,7 @@ def install_environment(
|
||||||
helpers.run_setup_cmd(
|
helpers.run_setup_cmd(
|
||||||
prefix,
|
prefix,
|
||||||
(
|
(
|
||||||
'cs',
|
executable,
|
||||||
'install',
|
'install',
|
||||||
'--default-channels=false',
|
'--default-channels=false',
|
||||||
f'--channel={channel}',
|
f'--channel={channel}',
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue