aboutsummaryrefslogtreecommitdiffstats
path: root/task
diff options
context:
space:
mode:
authorRoy Sommer <illBeRoy@users.noreply.github.com>2020-03-07 16:52:12 +0200
committerGitHub <noreply@github.com>2020-03-07 16:52:12 +0200
commit58a199d1313bf52cc74776fbde0bef245ba72329 (patch)
tree5b5f98cfffc0128c5ba4215f7cbb67c770b691d5 /task
parentupdated travis badge to indicate master status (diff)
downloadtaskipy2-58a199d1313bf52cc74776fbde0bef245ba72329.zip
Custom Runner (#11)
Diffstat (limited to '')
-rw-r--r--taskipy/run.py15
1 files changed, 13 insertions, 2 deletions
diff --git a/taskipy/run.py b/taskipy/run.py
index ab7824d..88c2ba9 100644
--- a/taskipy/run.py
+++ b/taskipy/run.py
@@ -6,8 +6,11 @@ from os import path
from typing import List
def run_task(task_name: str, args: List[str], cwd=os.curdir):
- def run_commands_and_bail_on_first_fail(cmds: List[str]) -> int:
+ def run_commands_and_bail_on_first_fail(cmds: List[str], runner: str = None) -> int:
for cmd in cmds:
+ if runner is not None:
+ cmd = f'{runner} {cmd}'
+
p = subprocess.Popen(cmd, shell=True, cwd=cwd)
try:
@@ -58,5 +61,13 @@ def run_task(task_name: str, args: List[str], cwd=os.curdir):
except KeyError:
pass
- exit_code = run_commands_and_bail_on_first_fail(commands)
+ try:
+ runner = pyproject['tool']['taskipy']['settings']['runner'].strip()
+ except KeyError:
+ runner = None
+ except AttributeError:
+ print('invalid value: runner is not a string. please check [tool.taskipy.settings.runner]')
+ sys.exit(1)
+
+ exit_code = run_commands_and_bail_on_first_fail(commands, runner=runner)
sys.exit(exit_code)