correctly use ENVIRONMENT_DIR

This commit is contained in:
Ben Asher 2017-01-13 11:20:25 -08:00
parent bea4e89a48
commit 8893127f27

View file

@ -1,12 +1,14 @@
from __future__ import unicode_literals from __future__ import unicode_literals
import os
from pre_commit.languages import helpers from pre_commit.languages import helpers
from pre_commit.util import clean_path_on_failure from pre_commit.util import clean_path_on_failure
from pre_commit.util import cwd from pre_commit.util import cwd
from pre_commit.languages import helpers from pre_commit.languages import helpers
from pre_commit.xargs import xargs from pre_commit.xargs import xargs
ENVIRONMENT_DIR = None ENVIRONMENT_DIR = 'swift_env'
BUILD_DIR = '.build' BUILD_DIR = '.build'
BUILD_CONFIG = 'release' BUILD_CONFIG = 'release'
@ -15,15 +17,23 @@ def install_environment(
version='default', version='default',
additional_dependencies=(), additional_dependencies=(),
): ):
directory = repo_cmd_runner.path(helpers.environment_dir(
ENVIRONMENT_DIR, 'default',
))
# Build the swift package # Build the swift package
with clean_path_on_failure(repo_cmd_runner.path(BUILD_DIR)): with clean_path_on_failure(directory):
os.mkdir(directory)
repo_cmd_runner.run(( repo_cmd_runner.run((
'swift', 'build', 'swift', 'build',
'-C', '{prefix}', '-C', '{prefix}',
'-c', BUILD_CONFIG, '-c', BUILD_CONFIG,
'--build-path', repo_cmd_runner.path(BUILD_DIR), '--build-path', os.path.join(directory, BUILD_DIR),
)) ))
def run_hook(repo_cmd_runner, hook, file_args): def run_hook(repo_cmd_runner, hook, file_args):
with(cwd(repo_cmd_runner.path(BUILD_DIR, BUILD_CONFIG))): directory = repo_cmd_runner.path(helpers.environment_dir(
ENVIRONMENT_DIR, 'default',
))
with(cwd(os.path.join(directory, BUILD_DIR, BUILD_CONFIG))):
return xargs(helpers.to_cmd(hook), file_args) return xargs(helpers.to_cmd(hook), file_args)