Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Recognize more possible taskfile config filenames #169

Merged
merged 2 commits into from
Jan 11, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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