Merge pull request #612 from Lucas-C/master

NodeJS hooks compatibilty fix for Cygwin - take 2
This commit is contained in:
Anthony Sottile
2017-09-06 08:49:31 -07:00
committed by GitHub

View File

@@ -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
@@ -17,11 +18,15 @@ 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
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'))),
)