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 934c24d
Showing 1 changed file with 22 additions and 10 deletions.
32 changes: 22 additions & 10 deletions src/mk/tools/taskfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,16 +20,28 @@ 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
validTaskfiles = [
"Taskfile.yml"
"taskfile.yml"
"Taskfile.yaml"
"taskfile.yaml"
"Taskfile.dist.yml"
"taskfile.dist.yml"
"Taskfile.dist.yaml"
"taskfile.dist.yaml"
]

for taskfile in validTaskfiles:
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(
f"{taskfile} config found but the tool is not installed. See https://taskfile.dev/installation/",
)
sys.exit(1)
return True
return False

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

0 comments on commit 934c24d

Please sign in to comment.