Skip to content

Commit

Permalink
Fix tag generation issues
Browse files Browse the repository at this point in the history
  • Loading branch information
relliv committed Nov 16, 2022
1 parent 574851c commit 324b974
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions src/Services/InstallerService.php
Original file line number Diff line number Diff line change
Expand Up @@ -112,15 +112,26 @@ public function setPackageDescription(string $description): self

public function setPackageTags(string $tags): self
{
// initial trim
$tags = trim(trim($tags, ','));
echo $tags;

// splice to array
$_tags = array_filter(explode(',', $tags), fn ($tag) => !empty($tag));
$_tags = array_map(fn ($tag) => trim(trim($tags, ',')), $_tags);

// extra trim for each tag
$_tags = array_map(fn ($_tag) => trim(trim($_tag, ',')), $_tags);

// order by asc
usort($_tags, fn ($a, $b) => strlen($a) - strlen($b));

// remove duplicate tags
$_tags = array_unique($_tags);

$_tags = implode('", "', $_tags);

$this->configs['PACKAGE_TAGS'] = "\"{$_tags}\"";
$this->configs['SETUP_PACKAGE_TAGS'] = true;
$this->configs['SETUP_PACKAGE_TAGS'] = !empty($_tags);

return $this;
}
Expand Down

0 comments on commit 324b974

Please sign in to comment.