|
8 | 8 | from pre_commit.envcontext import Var |
9 | 9 | from pre_commit.languages import helpers |
10 | 10 | from pre_commit.util import clean_path_on_failure |
| 11 | +from pre_commit.util import cmd_output |
11 | 12 | from pre_commit.xargs import xargs |
12 | 13 |
|
13 | 14 |
|
|
16 | 17 | healthy = helpers.basic_healthy |
17 | 18 |
|
18 | 19 |
|
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 |
21 | 26 | return ( |
22 | 27 | ('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), |
25 | 30 | ('NODE_PATH', os.path.join(venv, 'lib', 'node_modules')), |
26 | 31 | ('PATH', (os.path.join(venv, 'bin'), os.pathsep, Var('PATH'))), |
27 | 32 | ) |
|
0 commit comments