-
Notifications
You must be signed in to change notification settings - Fork 581
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
AlexBear: Check if wrong alex is installed
Alex has a name clash with another tool in the haskell toolkit. Hence, we check here by reading the `--help` of `alex` and checking whether this is indeed the correct tool or not. Fixes #776
- Loading branch information
1 parent
bfd61fb
commit fa70e92
Showing
2 changed files
with
54 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,6 @@ | ||
import subprocess | ||
import sys | ||
|
||
from coalib.bearlib.abstractions.Linter import linter | ||
from coalib.bears.requirements.NpmRequirement import NpmRequirement | ||
|
||
|
@@ -18,6 +21,30 @@ class AlexBear: | |
AUTHORS_EMAILS = {'[email protected]'} | ||
LICENSE = 'AGPL-3.0' | ||
|
||
@classmethod | ||
def check_prerequisites(cls): | ||
parent_prereqs = super().check_prerequisites() | ||
if parent_prereqs is not True: # pragma: no cover | ||
return parent_prereqs | ||
|
||
incorrect_pkg_msg = ( | ||
"Please ensure that the package that has been installed is the " | ||
"one to 'Catch insensitive, inconsiderate writing'. This can be " | ||
"verified by running `alex --help` and seeing what it does.") | ||
try: | ||
output = subprocess.check_output(("alex", "--help"), | ||
stderr=subprocess.STDOUT) | ||
except (OSError, subprocess.CalledProcessError): | ||
return ("The `alex` package could not be verified. " + | ||
incorrect_pkg_msg) | ||
else: | ||
output = output.decode(sys.getfilesystemencoding()) | ||
if "Catch insensitive, inconsiderate writing" in output: | ||
return True | ||
else: | ||
return ("The `alex` package that's been installed seems to " | ||
"be incorrect. " + incorrect_pkg_msg) | ||
|
||
@staticmethod | ||
def create_arguments(filename, file, config_file): | ||
return filename, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters