mirror of
https://github.com/pre-commit/pre-commit.git
synced 2026-02-19 17:14:43 +04:00
Don't use system node.
It's usually kind of buggy and interacts poorly with local installs.
This commit is contained in:
parent
ed86307dc4
commit
e8a870dbbb
1 changed files with 9 additions and 21 deletions
|
|
@ -4,7 +4,6 @@ import contextlib
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
from pre_commit.languages import helpers
|
from pre_commit.languages import helpers
|
||||||
from pre_commit.prefixed_command_runner import CalledProcessError
|
|
||||||
from pre_commit.util import clean_path_on_failure
|
from pre_commit.util import clean_path_on_failure
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -27,26 +26,15 @@ def install_environment(repo_cmd_runner, version='default'):
|
||||||
|
|
||||||
env_dir = repo_cmd_runner.path(ENVIRONMENT_DIR)
|
env_dir = repo_cmd_runner.path(ENVIRONMENT_DIR)
|
||||||
with clean_path_on_failure(env_dir):
|
with clean_path_on_failure(env_dir):
|
||||||
if version == 'default':
|
cmd = [
|
||||||
# In the default case we attempt to install system node and if that
|
|
||||||
# doesn't work we use --prebuilt
|
|
||||||
try:
|
|
||||||
with clean_path_on_failure(env_dir):
|
|
||||||
repo_cmd_runner.run([
|
|
||||||
sys.executable, '-m', 'nodeenv', '-n', 'system',
|
|
||||||
'{{prefix}}{0}'.format(ENVIRONMENT_DIR),
|
|
||||||
])
|
|
||||||
except CalledProcessError:
|
|
||||||
# TODO: log failure here
|
|
||||||
repo_cmd_runner.run([
|
|
||||||
sys.executable, '-m', 'nodeenv', '--prebuilt',
|
sys.executable, '-m', 'nodeenv', '--prebuilt',
|
||||||
'{{prefix}}{0}'.format(ENVIRONMENT_DIR)
|
'{{prefix}}{0}'.format(ENVIRONMENT_DIR),
|
||||||
])
|
]
|
||||||
else:
|
|
||||||
repo_cmd_runner.run([
|
if version != 'default':
|
||||||
sys.executable, '-m', 'nodeenv', '--prebuilt', '-n', version,
|
cmd.extend(['-n', version])
|
||||||
'{{prefix}}{0}'.format(ENVIRONMENT_DIR)
|
|
||||||
])
|
repo_cmd_runner.run(cmd)
|
||||||
|
|
||||||
with in_env(repo_cmd_runner) as node_env:
|
with in_env(repo_cmd_runner) as node_env:
|
||||||
node_env.run('cd {prefix} && npm install -g')
|
node_env.run('cd {prefix} && npm install -g')
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue