Skip to content

Commit

Permalink
coursier: Add support for both cs and coursier executable names
Browse files Browse the repository at this point in the history
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
  • Loading branch information
Holzhaus committed Mar 17, 2022
1 parent da55e97 commit 7846572
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion pre_commit/languages/coursier.py
Expand Up @@ -27,6 +27,14 @@ def install_environment(
helpers.assert_version_default('coursier', version)
helpers.assert_no_additional_deps('coursier', additional_dependencies)

# Support both possible executable names (either "cs" or "coursier")
executable = next(filter(helpers.exe_exists, ('cs', 'coursier')), None)
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))
channel = prefix.path('.pre-commit-channel')
with clean_path_on_failure(envdir):
Expand All @@ -36,7 +44,7 @@ def install_environment(
helpers.run_setup_cmd(
prefix,
(
'cs',
executable,
'install',
'--default-channels=false',
f'--channel={channel}',
Expand Down

0 comments on commit 7846572

Please sign in to comment.