Skip to content

Commit

Permalink
add possible taskfile locations
Browse files Browse the repository at this point in the history
  • Loading branch information
Haseeb Majid committed Nov 25, 2023
1 parent 7a6ae1f commit 209e2a8
Showing 1 changed file with 23 additions and 10 deletions.
33 changes: 23 additions & 10 deletions src/mk/tools/taskfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,16 +20,29 @@ def __init__(self, path=".") -> None:
self.executable = ""

def is_present(self, path: Path) -> bool:
if os.path.isfile(os.path.join(path, "taskfile.yml")):
# On some Linux distros might be exposed as taskfile in order to
# avoid clashing with the other Task Warrior executable https://taskwarrior.org/
self.executable = shutil.which("taskfile") or shutil.which("task") or ""
if not self.executable:
logging.error(
"taskfile.yml config found but the tool is not installed. See https://taskfile.dev/installation/",
)
sys.exit(1)
return True
valid_taskfiles = [
"Taskfile.yml"
"taskfile.yml"
"Taskfile.yaml"
"taskfile.yaml"
"Taskfile.dist.yml"
"taskfile.dist.yml"
"Taskfile.dist.yaml"
"taskfile.dist.yaml",
]

for taskfile in valid_taskfiles:
if os.path.isfile(os.path.join(path, taskfile)):
# On some Linux distros might be exposed as taskfile in order to
# avoid clashing with the other Task Warrior executable https://taskwarrior.org/
self.executable = shutil.which(taskfile) or shutil.which("task") or ""
if not self.executable:
logging.error(
"%s config found but the tool is not installed. See https://taskfile.dev/installation/",
taskfile,
)
sys.exit(1)
return True
return False

def actions(self) -> list[Action]:
Expand Down

0 comments on commit 209e2a8

Please sign in to comment.