Skip to content

Commit e465129

Browse files
committed
NodeJS hooks compatibilty fix for Cygwin - take 2
1 parent c86fa14 commit e465129

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

pre_commit/languages/node.py

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
from pre_commit.envcontext import Var
99
from pre_commit.languages import helpers
1010
from pre_commit.util import clean_path_on_failure
11+
from pre_commit.util import cmd_output
1112
from pre_commit.xargs import xargs
1213

1314

@@ -16,12 +17,16 @@
1617
healthy = helpers.basic_healthy
1718

1819

19-
def get_env_patch(venv): # pragma: windows no cover
20-
config = os.path.join(venv, 'bin') if sys.platform == 'cygwin' else venv
20+
def get_env_patch(venv): # pragma: windows no cover
21+
if sys.platform == 'cygwin': # pragma: no cover
22+
_, win_venv, _ = cmd_output('cygpath', '-w', venv)
23+
install_prefix = r'{}\bin'.format(win_venv.strip())
24+
else:
25+
install_prefix = venv
2126
return (
2227
('NODE_VIRTUAL_ENV', venv),
23-
('NPM_CONFIG_PREFIX', config),
24-
('npm_config_prefix', config),
28+
('NPM_CONFIG_PREFIX', install_prefix),
29+
('npm_config_prefix', install_prefix),
2530
('NODE_PATH', os.path.join(venv, 'lib', 'node_modules')),
2631
('PATH', (os.path.join(venv, 'bin'), os.pathsep, Var('PATH'))),
2732
)

0 commit comments

Comments
 (0)