From 0189c9d7af03907ceca455d54d3d2c0e4a27a769 Mon Sep 17 00:00:00 2001 From: Pavel Shevaev Date: Thu, 6 Mar 2025 13:56:26 +0300 Subject: [PATCH] Adding more convenience stuff --- artefact.inc.php | 7 ++++++- taskman.inc.php | 6 ++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/artefact.inc.php b/artefact.inc.php index 71d6edd..4406cda 100644 --- a/artefact.inc.php +++ b/artefact.inc.php @@ -87,7 +87,12 @@ class TaskmanArtefact function initSources(?\taskman\TaskmanFileChanges $file_changes) { - foreach($this->getSourcesSpec() as $src_idx => $src_spec) + $all_src_specs = $this->getSourcesSpec(); + //let's process a convenience special case + if(count($all_src_specs) > 0 && !is_array($all_src_specs[0])) + $all_src_specs = [$all_src_specs]; + + foreach($all_src_specs as $src_idx => $src_spec) { //[[dir1, dir2, ..], [ext1, ext2, ..]] if(is_array($src_spec) && count($src_spec) == 2 && diff --git a/taskman.inc.php b/taskman.inc.php index d7befd2..85f25ec 100644 --- a/taskman.inc.php +++ b/taskman.inc.php @@ -126,6 +126,7 @@ class TaskmanTask $specs = $this->getPropOr("artefacts", array()); if(is_callable($specs)) $specs = $specs(); + if(is_array($specs)) { foreach($specs as $dst => $src_spec) @@ -135,6 +136,11 @@ class TaskmanTask return $artefacts; } + function getArtefact(int $idx) : artefact\TaskmanArtefact + { + return $this->getArtefacts()[$idx]; + } + function getFileChanges() : ?TaskmanFileChanges { return $this->file_changes;