Skip to content

Commit d4c9f90

Browse files
committed
Fix node runner for running without a system-level node installed.
1 parent c300a11 commit d4c9f90

File tree

2 files changed

+7
-8
lines changed

2 files changed

+7
-8
lines changed

pre_commit/languages/helpers.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ def env_prefix(self):
2424
"""
2525
raise NotImplementedError
2626

27-
def run(self, cmd, stdin=None, **kwargs):
27+
def run(self, cmd, stdin=None):
2828
"""Returns (returncode, stdout, stderr)."""
2929
proc = subprocess.Popen(
3030
['bash', '-c', ' '.join([self.env_prefix, cmd])],

pre_commit/languages/node.py

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -31,13 +31,12 @@ def install_environment():
3131
with python.in_env() as python_env:
3232
python_env.run('pip install nodeenv')
3333

34-
try:
35-
# Try and use the system level node executable first
36-
python_env.run('nodeenv -n system {0}'.format(NODE_ENV))
37-
except Exception:
38-
# TODO: log exception here
39-
# cleanup
40-
local.path(NODE_ENV).remove()
34+
# Try and use the system level node executable first
35+
retcode, _, _ = python_env.run('nodeenv -n system {0}'.format(NODE_ENV))
36+
# TODO: log failure here
37+
# cleanup
38+
if retcode:
39+
local.path(NODE_ENV).delete()
4140
python_env.run('nodeenv --jobs 4 {0}'.format(NODE_ENV))
4241

4342
with in_env() as node_env:

0 commit comments

Comments
 (0)