mirror of
https://github.com/pre-commit/pre-commit.git
synced 2026-01-13 20:40:08 -06:00
NodeJS hooks compatibilty fix for Cygwin - take 2
This commit is contained in:
@@ -8,6 +8,7 @@ from pre_commit.envcontext import envcontext
|
||||
from pre_commit.envcontext import Var
|
||||
from pre_commit.languages import helpers
|
||||
from pre_commit.util import clean_path_on_failure
|
||||
from pre_commit.util import cmd_output
|
||||
from pre_commit.xargs import xargs
|
||||
|
||||
|
||||
@@ -16,12 +17,16 @@ get_default_version = helpers.basic_get_default_version
|
||||
healthy = helpers.basic_healthy
|
||||
|
||||
|
||||
def get_env_patch(venv): # pragma: windows no cover
|
||||
config = os.path.join(venv, 'bin') if sys.platform == 'cygwin' else venv
|
||||
def get_env_patch(venv): # pragma: windows no cover
|
||||
if sys.platform == 'cygwin': # pragma: no cover
|
||||
_, win_venv, _ = cmd_output('cygpath', '-w', venv)
|
||||
install_prefix = r'{}\bin'.format(win_venv.strip())
|
||||
else:
|
||||
install_prefix = venv
|
||||
return (
|
||||
('NODE_VIRTUAL_ENV', venv),
|
||||
('NPM_CONFIG_PREFIX', config),
|
||||
('npm_config_prefix', config),
|
||||
('NPM_CONFIG_PREFIX', install_prefix),
|
||||
('npm_config_prefix', install_prefix),
|
||||
('NODE_PATH', os.path.join(venv, 'lib', 'node_modules')),
|
||||
('PATH', (os.path.join(venv, 'bin'), os.pathsep, Var('PATH'))),
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user