Skip to content

Commit 09ac7fc

Browse files
author
Greg Bowler
authored
fix: build task once per execution, not once per file (#148)
closes #147
1 parent 2c99952 commit 09ac7fc

File tree

2 files changed

+9
-6
lines changed

2 files changed

+9
-6
lines changed

src/Build.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,12 +45,12 @@ public function check(array &$errors = null):int {
4545
*/
4646
public function build(array &$errors = null):array {
4747
$updatedTasks = [];
48-
foreach($this->taskList as $pathMatch => $task) {
48+
foreach($this->taskList as $task) {
4949
if($task->build($errors)) {
5050
$updatedTasks []= $task;
5151
}
5252
}
5353

5454
return $updatedTasks;
5555
}
56-
}
56+
}

src/Task.php

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -57,20 +57,23 @@ public function check(array &$errors = null):void {
5757
}
5858

5959
public function build(array &$errors = null):bool {
60-
$changes = false;
60+
$hashMiss = false;
6161

6262
foreach(Glob::glob($this->absolutePath) as $matchedPath) {
6363
$hash = filemtime($matchedPath);
6464
$existingHash = $this->fileHashList[$matchedPath] ?? null;
6565

6666
if($hash !== $existingHash) {
67-
$changes = $this->execute($errors);
67+
$hashMiss = true;
6868
}
6969

7070
$this->fileHashList[$matchedPath] = $hash;
7171
}
7272

73-
return $changes;
73+
if($hashMiss) {
74+
return $this->execute($errors);
75+
}
76+
return false;
7477
}
7578

7679
public function requirementFromRequireBlockItem(
@@ -160,4 +163,4 @@ protected function isAbsolutePath(string $path):bool {
160163
// Windows:
161164
|| preg_match('~\A[A-Z]:(?![^/\\\\])~i',$path) > 0;
162165
}
163-
}
166+
}

0 commit comments

Comments
 (0)