Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit e8a870d

Browse files
committed
Don't use system node.
It's usually kind of buggy and interacts poorly with local installs.
1 parent ed86307 commit e8a870d

1 file changed

Lines changed: 9 additions & 21 deletions

File tree

pre_commit/languages/node.py

Lines changed: 9 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
import sys
55

66
from pre_commit.languages import helpers
7-
from pre_commit.prefixed_command_runner import CalledProcessError
87
from pre_commit.util import clean_path_on_failure
98

109

@@ -27,26 +26,15 @@ def install_environment(repo_cmd_runner, version='default'):
2726

2827
env_dir = repo_cmd_runner.path(ENVIRONMENT_DIR)
2928
with clean_path_on_failure(env_dir):
30-
if version == 'default':
31-
# In the default case we attempt to install system node and if that
32-
# doesn't work we use --prebuilt
33-
try:
34-
with clean_path_on_failure(env_dir):
35-
repo_cmd_runner.run([
36-
sys.executable, '-m', 'nodeenv', '-n', 'system',
37-
'{{prefix}}{0}'.format(ENVIRONMENT_DIR),
38-
])
39-
except CalledProcessError:
40-
# TODO: log failure here
41-
repo_cmd_runner.run([
42-
sys.executable, '-m', 'nodeenv', '--prebuilt',
43-
'{{prefix}}{0}'.format(ENVIRONMENT_DIR)
44-
])
45-
else:
46-
repo_cmd_runner.run([
47-
sys.executable, '-m', 'nodeenv', '--prebuilt', '-n', version,
48-
'{{prefix}}{0}'.format(ENVIRONMENT_DIR)
49-
])
29+
cmd = [
30+
sys.executable, '-m', 'nodeenv', '--prebuilt',
31+
'{{prefix}}{0}'.format(ENVIRONMENT_DIR),
32+
]
33+
34+
if version != 'default':
35+
cmd.extend(['-n', version])
36+
37+
repo_cmd_runner.run(cmd)
5038

5139
with in_env(repo_cmd_runner) as node_env:
5240
node_env.run('cd {prefix} && npm install -g')

0 commit comments

Comments
 (0)