Skip to content

Commit

Permalink
Recognize more possible taskfile config filenames (#169)
Browse files Browse the repository at this point in the history
Co-authored-by: Haseeb Majid <[email protected]>
Co-authored-by: Sorin Sbarnea <[email protected]>
  • Loading branch information
3 people authored Jan 11, 2024
1 parent 5657805 commit 86f6fe7
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 86f6fe7

Please sign in to comment.