Skip to content

Commit

Permalink
exit with error on failed library install (#2752)
Browse files Browse the repository at this point in the history
  • Loading branch information
emmachughes authored Aug 20, 2024
1 parent 70314e2 commit e70323c
Showing 1 changed file with 11 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -43,24 +43,26 @@ public function handle(): int
}

$cacheUpdate = $this->call('h5p:library-hub-cache', ['--force' => $this->option('force-cache')]);
if ($cacheUpdate === Command::SUCCESS) {
$this->install();
} else {

if ($cacheUpdate !== Command::SUCCESS) {
return $cacheUpdate;
}

return Command::SUCCESS;
return $this->install() ? Command::SUCCESS : Command::FAILURE;
}

private function install(): int
/**
* @return bool True if success, otherwise false
*/
private function install(): bool
{
$hasError = false;
$success = true;
$libraries = $this->argument('library');

foreach ($libraries as $library) {
$cache = H5PLibrariesHubCache::where(DB::raw('lower(name)'), '=', Str::lower($library))->first();
if (!$cache) {
$hasError = true;
$success = false;
$this->error(" - $library: Not found in cache, skipping");
continue;
}
Expand All @@ -77,7 +79,7 @@ private function install(): int
$this->info('No change, already up to date');
}
} else {
$hasError = true;
$success = false;
$this->error('Failed');
if (isset($result['message'])) {
$this->error(' ' . $result['message']);
Expand All @@ -87,6 +89,6 @@ private function install(): int

$this->newLine();

return $hasError ? Command::FAILURE : Command::SUCCESS;
return $success;
}
}

0 comments on commit e70323c

Please sign in to comment.