mirror of
https://github.com/pre-commit/pre-commit.git
synced 2026-02-17 08:14:42 +04:00
Merge remote-tracking branch 'origin/master' into performance_test
Conflicts: pre_commit/languages/python.py
This commit is contained in:
commit
ca02afd0b3
4 changed files with 59 additions and 20 deletions
|
|
@ -1,7 +1,44 @@
|
|||
import contextlib
|
||||
from plumbum import local
|
||||
|
||||
from pre_commit.languages import helpers
|
||||
from pre_commit.languages import python
|
||||
|
||||
|
||||
NODE_ENV = 'node_env'
|
||||
|
||||
|
||||
class NodeEnv(object):
|
||||
def __init__(self, py_env):
|
||||
self.py_env = py_env
|
||||
self.env_prefix = '. {0}/bin/activate &&'.format(NODE_ENV)
|
||||
|
||||
def run(self, cmd, **kwargs):
|
||||
return self.py_env.run(' '.join([self.env_prefix, cmd]), **kwargs)
|
||||
|
||||
|
||||
@contextlib.contextmanager
|
||||
def in_env(py_env):
|
||||
yield NodeEnv(py_env)
|
||||
|
||||
|
||||
def install_environment():
|
||||
raise NotImplementedError
|
||||
assert local.path('package.json').exists()
|
||||
|
||||
if local.path('node_env').exists():
|
||||
return
|
||||
|
||||
local['virtualenv'][python.PY_ENV]()
|
||||
|
||||
with python.in_env() as python_env:
|
||||
python_env.run('pip install nodeenv')
|
||||
python_env.run('nodeenv {0}'.format(NODE_ENV))
|
||||
|
||||
with in_env(python_env) as node_env:
|
||||
node_env.run('npm install -g')
|
||||
|
||||
|
||||
def run_hook(hook, file_args):
|
||||
raise NotImplementedError
|
||||
with python.in_env() as py_env:
|
||||
with in_env(py_env) as node_env:
|
||||
return helpers.run_hook(node_env, hook, file_args)
|
||||
Loading…
Add table
Add a link
Reference in a new issue