Skip to content

Commit 324b974

Browse files
committed
Fix tag generation issues
1 parent 574851c commit 324b974

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

src/Services/InstallerService.php

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -112,15 +112,26 @@ public function setPackageDescription(string $description): self
112112

113113
public function setPackageTags(string $tags): self
114114
{
115+
// initial trim
115116
$tags = trim(trim($tags, ','));
117+
echo $tags;
116118

119+
// splice to array
117120
$_tags = array_filter(explode(',', $tags), fn ($tag) => !empty($tag));
118-
$_tags = array_map(fn ($tag) => trim(trim($tags, ',')), $_tags);
121+
122+
// extra trim for each tag
123+
$_tags = array_map(fn ($_tag) => trim(trim($_tag, ',')), $_tags);
124+
125+
// order by asc
126+
usort($_tags, fn ($a, $b) => strlen($a) - strlen($b));
127+
128+
// remove duplicate tags
119129
$_tags = array_unique($_tags);
130+
120131
$_tags = implode('", "', $_tags);
121132

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

125136
return $this;
126137
}

0 commit comments

Comments
 (0)