Skip to content

Commit b3dff8f

Browse files
committed
guidelines: compose guidelines more neatly
1 parent 2f24bf9 commit b3dff8f

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

src/Install/GuidelineComposer.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,8 @@ public function config(GuidelineConfig $config): self
3535
public function compose(): string
3636
{
3737
return $this->guidelines()
38-
->map(fn ($content, $key) => "# {$key}\n{$content}\n")
39-
->join("\n\n====\n\n");
38+
->map(fn ($content, $key) => "\n=== {$key} ===\n\n{$content}")
39+
->join("\n\n");
4040
}
4141

4242
/**

src/Install/GuidelineWriter.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,13 +56,15 @@ public function write(string $guidelines): int
5656
$newContent = preg_replace($pattern, $replacement, $content, 1);
5757
$replaced = true;
5858
} else {
59-
// No existing guidelines found, append to end
59+
// No existing Boost guidelines found, append to end of existing file
6060
$frontMatter = '';
6161
if ($this->agent->frontmatter() && ! str_contains($content, "\n---\n")) {
6262
$frontMatter = "---\nalwaysApply: true\n---\n";
6363
}
6464

65-
$newContent = $frontMatter.rtrim($content)."\n\n\n".$replacement;
65+
$existingContent = rtrim($content);
66+
$separatingNewlines = empty($existingContent) ? '' : "\n\n===\n\n";
67+
$newContent = $frontMatter.$existingContent.$separatingNewlines.$replacement;
6668
}
6769

6870
if (ftruncate($handle, 0) === false || fseek($handle, 0) === -1) {

0 commit comments

Comments
 (0)