mirror of
https://github.com/pre-commit/pre-commit.git
synced 2026-02-17 08:14:42 +04:00
Fix node runner for running without a system-level node installed.
This commit is contained in:
parent
c300a11a97
commit
d4c9f9075e
2 changed files with 7 additions and 8 deletions
|
|
@ -24,7 +24,7 @@ class Environment(object):
|
||||||
"""
|
"""
|
||||||
raise NotImplementedError
|
raise NotImplementedError
|
||||||
|
|
||||||
def run(self, cmd, stdin=None, **kwargs):
|
def run(self, cmd, stdin=None):
|
||||||
"""Returns (returncode, stdout, stderr)."""
|
"""Returns (returncode, stdout, stderr)."""
|
||||||
proc = subprocess.Popen(
|
proc = subprocess.Popen(
|
||||||
['bash', '-c', ' '.join([self.env_prefix, cmd])],
|
['bash', '-c', ' '.join([self.env_prefix, cmd])],
|
||||||
|
|
|
||||||
|
|
@ -31,13 +31,12 @@ def install_environment():
|
||||||
with python.in_env() as python_env:
|
with python.in_env() as python_env:
|
||||||
python_env.run('pip install nodeenv')
|
python_env.run('pip install nodeenv')
|
||||||
|
|
||||||
try:
|
# Try and use the system level node executable first
|
||||||
# Try and use the system level node executable first
|
retcode, _, _ = python_env.run('nodeenv -n system {0}'.format(NODE_ENV))
|
||||||
python_env.run('nodeenv -n system {0}'.format(NODE_ENV))
|
# TODO: log failure here
|
||||||
except Exception:
|
# cleanup
|
||||||
# TODO: log exception here
|
if retcode:
|
||||||
# cleanup
|
local.path(NODE_ENV).delete()
|
||||||
local.path(NODE_ENV).remove()
|
|
||||||
python_env.run('nodeenv --jobs 4 {0}'.format(NODE_ENV))
|
python_env.run('nodeenv --jobs 4 {0}'.format(NODE_ENV))
|
||||||
|
|
||||||
with in_env() as node_env:
|
with in_env() as node_env:
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue