mirror of
https://github.com/pre-commit/pre-commit.git
synced 2026-02-19 17:14:43 +04:00
Merge branch 'master' of github.com:pre-commit/pre-commit
This commit is contained in:
commit
cb3699007e
4 changed files with 63 additions and 4 deletions
|
|
@ -13,4 +13,12 @@
|
||||||
hooks:
|
hooks:
|
||||||
-
|
-
|
||||||
id: jshint
|
id: jshint
|
||||||
files: '*.js'
|
files: '*.js'
|
||||||
|
|
||||||
|
-
|
||||||
|
repo: git@github.com:pre-commit/scss-lint
|
||||||
|
sha: 425536b1b77d9e836068edde4fb3101bea6e7dd8
|
||||||
|
hooks:
|
||||||
|
-
|
||||||
|
id: scss-lint
|
||||||
|
files: '*.scss'
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,36 @@
|
||||||
|
|
||||||
|
import contextlib
|
||||||
|
from plumbum import local
|
||||||
|
|
||||||
|
from pre_commit.languages import helpers
|
||||||
|
|
||||||
|
|
||||||
|
RVM_ENV = 'rvm_env'
|
||||||
|
|
||||||
|
|
||||||
|
class RubyEnv(object):
|
||||||
|
def __init__(self):
|
||||||
|
self.env_prefix = '. {0}/.rvm/scripts/rvm'.format(RVM_ENV)
|
||||||
|
|
||||||
|
def run(self, cmd, **kwargs):
|
||||||
|
return local['bash']['-c', ' '.join([self.env_prefix, cmd])].run(**kwargs)
|
||||||
|
|
||||||
|
|
||||||
|
@contextlib.contextmanager
|
||||||
|
def in_env():
|
||||||
|
yield RubyEnv()
|
||||||
|
|
||||||
|
|
||||||
def install_environment():
|
def install_environment():
|
||||||
raise NotImplementedError
|
# Return immediately if we already have a virtualenv
|
||||||
|
if local.path(RVM_ENV).exists():
|
||||||
|
return
|
||||||
|
|
||||||
|
local['__rvm-env.sh'][RVM_ENV]()
|
||||||
|
with in_env() as env:
|
||||||
|
env.run('bundle install')
|
||||||
|
|
||||||
|
|
||||||
def run_hook(hook, file_args):
|
def run_hook(hook, file_args):
|
||||||
raise NotImplementedError
|
with in_env() as env:
|
||||||
|
return helpers.run_hook(env, hook, file_args)
|
||||||
19
scripts/__rvm-env.sh
Executable file
19
scripts/__rvm-env.sh
Executable file
|
|
@ -0,0 +1,19 @@
|
||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
if [ $# -ne 1 ] || [ $1 = "--help" ] || [ $1 = "-h" ]; then
|
||||||
|
echo "usage: $0 RVM_ENV_DIR [--help]"
|
||||||
|
echo " RVM_ENV_DIR - Directory to create rvm environment in"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
|
||||||
|
# Get the rvm installer. This is a known version that works reasonably well
|
||||||
|
RVM_INSTALLER=https://raw.github.com/wayneeseguin/rvm/d80282de1f2b2b1ff51740e05d9f5d84ebf3209f/binscripts/rvm-installer
|
||||||
|
|
||||||
|
env_dir=$1
|
||||||
|
mkdir "$env_dir" || exit 1
|
||||||
|
full_env_dir=`pwd`"/$env_dir"
|
||||||
|
|
||||||
|
|
||||||
|
\curl -L "$RVM_INSTALLER" | HOME=$full_env_dir bash -s -- stable --user-install --ignore-dotfiles || exit 1
|
||||||
|
bash -c '. '"$env_dir"'/.rvm/scripts/rvm && rvm install ruby' || exit 1
|
||||||
5
setup.py
5
setup.py
|
|
@ -23,5 +23,8 @@ setup(
|
||||||
'validate-config = pre_commit.entry_points:validate_config_func',
|
'validate-config = pre_commit.entry_points:validate_config_func',
|
||||||
'validate-manifest = pre_commit.entry_points:validate_manifest_func',
|
'validate-manifest = pre_commit.entry_points:validate_manifest_func',
|
||||||
],
|
],
|
||||||
}
|
},
|
||||||
|
scripts=[
|
||||||
|
'scripts/__rvm-env.sh',
|
||||||
|
],
|
||||||
)
|
)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue