mirror of
https://github.com/pre-commit/pre-commit.git
synced 2026-04-15 18:11:48 +04:00
Fail if grep cannot be executed
This commit is contained in:
parent
0e2c3c1ff9
commit
f821f52ba3
1 changed files with 8 additions and 1 deletions
|
|
@ -4,6 +4,7 @@ from sys import platform
|
||||||
|
|
||||||
from pre_commit.xargs import xargs
|
from pre_commit.xargs import xargs
|
||||||
|
|
||||||
|
import os
|
||||||
|
|
||||||
ENVIRONMENT_DIR = None
|
ENVIRONMENT_DIR = None
|
||||||
|
|
||||||
|
|
@ -18,9 +19,15 @@ def install_environment(
|
||||||
|
|
||||||
|
|
||||||
def run_hook(repo_cmd_runner, hook, file_args):
|
def run_hook(repo_cmd_runner, hook, file_args):
|
||||||
|
grep_command = 'ggrep' if platform == 'darwin' else 'grep'
|
||||||
|
|
||||||
|
# Determine if grep is installed on system
|
||||||
|
if os.system('which ' + grep_command) != 0:
|
||||||
|
raise AssertionError('Cannot execute grep command: ' + grep_command)
|
||||||
|
|
||||||
# For PCRE the entry is the regular expression to match
|
# For PCRE the entry is the regular expression to match
|
||||||
cmd = (
|
cmd = (
|
||||||
'ggrep' if platform == 'darwin' else 'grep',
|
grep_command,
|
||||||
'-H', '-n', '-P',
|
'-H', '-n', '-P',
|
||||||
) + tuple(hook['args']) + (hook['entry'],)
|
) + tuple(hook['args']) + (hook['entry'],)
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue