mirror of
https://github.com/pre-commit/pre-commit.git
synced 2026-02-17 08:14:42 +04:00
SwiftPM support
This commit is contained in:
parent
cc0f40fc96
commit
bea4e89a48
2 changed files with 31 additions and 0 deletions
|
|
@ -6,6 +6,7 @@ from pre_commit.languages import pcre
|
||||||
from pre_commit.languages import python
|
from pre_commit.languages import python
|
||||||
from pre_commit.languages import ruby
|
from pre_commit.languages import ruby
|
||||||
from pre_commit.languages import script
|
from pre_commit.languages import script
|
||||||
|
from pre_commit.languages import swift
|
||||||
from pre_commit.languages import system
|
from pre_commit.languages import system
|
||||||
|
|
||||||
# A language implements the following constant and two functions in its module:
|
# A language implements the following constant and two functions in its module:
|
||||||
|
|
@ -47,6 +48,7 @@ languages = {
|
||||||
'python': python,
|
'python': python,
|
||||||
'ruby': ruby,
|
'ruby': ruby,
|
||||||
'script': script,
|
'script': script,
|
||||||
|
'swift': swift,
|
||||||
'system': system,
|
'system': system,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
29
pre_commit/languages/swift.py
Normal file
29
pre_commit/languages/swift.py
Normal file
|
|
@ -0,0 +1,29 @@
|
||||||
|
from __future__ import unicode_literals
|
||||||
|
|
||||||
|
from pre_commit.languages import helpers
|
||||||
|
from pre_commit.util import clean_path_on_failure
|
||||||
|
from pre_commit.util import cwd
|
||||||
|
from pre_commit.languages import helpers
|
||||||
|
from pre_commit.xargs import xargs
|
||||||
|
|
||||||
|
ENVIRONMENT_DIR = None
|
||||||
|
BUILD_DIR = '.build'
|
||||||
|
BUILD_CONFIG = 'release'
|
||||||
|
|
||||||
|
def install_environment(
|
||||||
|
repo_cmd_runner,
|
||||||
|
version='default',
|
||||||
|
additional_dependencies=(),
|
||||||
|
):
|
||||||
|
# Build the swift package
|
||||||
|
with clean_path_on_failure(repo_cmd_runner.path(BUILD_DIR)):
|
||||||
|
repo_cmd_runner.run((
|
||||||
|
'swift', 'build',
|
||||||
|
'-C', '{prefix}',
|
||||||
|
'-c', BUILD_CONFIG,
|
||||||
|
'--build-path', repo_cmd_runner.path(BUILD_DIR),
|
||||||
|
))
|
||||||
|
|
||||||
|
def run_hook(repo_cmd_runner, hook, file_args):
|
||||||
|
with(cwd(repo_cmd_runner.path(BUILD_DIR, BUILD_CONFIG))):
|
||||||
|
return xargs(helpers.to_cmd(hook), file_args)
|
||||||
Loading…
Add table
Add a link
Reference in a new issue