executable-stories-formatters 1.17.0 → 1.18.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -7723,27 +7723,39 @@ var ReportGenerator = class {
7723
7723
  bundleAssets(htmlPath, { allowMissing: this.options.allowMissingAssets });
7724
7724
  }
7725
7725
  }
7726
- const astroPaths = results.get("astro-markdown");
7727
- if (astroPaths) {
7728
- for (const mdPath of astroPaths) {
7729
- const content = await fsPromises2.readFile(mdPath, "utf8");
7730
- const mdDir = path7.dirname(mdPath);
7731
- const assetsDir = path7.resolve(this.options.astro.assetsDir);
7732
- const result = copyMarkdownAssets({
7733
- markdown: content,
7734
- markdownDir: mdDir,
7735
- assetsDir,
7736
- assetsBaseUrl: this.options.astro.assetsBaseUrl,
7737
- allowMissing: this.options.allowMissingAssets
7738
- });
7739
- if (result.copiedCount > 0 || result.missingCount > 0) {
7740
- await this.deps.writeFile(mdPath, result.markdown);
7741
- }
7742
- }
7743
- }
7726
+ await this.bundleMarkdownAssets(results.get("markdown"), (markdownDir) => ({
7727
+ assetsDir: path7.join(markdownDir, "assets"),
7728
+ assetsBaseUrl: "assets"
7729
+ }));
7730
+ await this.bundleMarkdownAssets(results.get("astro-markdown"), () => ({
7731
+ // assetsDir is resolved from CWD (same as outputDir), not relative to outputDir
7732
+ assetsDir: path7.resolve(this.options.astro.assetsDir),
7733
+ assetsBaseUrl: this.options.astro.assetsBaseUrl
7734
+ }));
7744
7735
  }
7745
7736
  return results;
7746
7737
  }
7738
+ /**
7739
+ * Copy every local asset these markdown reports reference into an assets
7740
+ * directory and rewrite the refs. The destination is computed per report
7741
+ * because colocated output writes one per source file.
7742
+ */
7743
+ async bundleMarkdownAssets(markdownPaths, target) {
7744
+ if (!markdownPaths) return;
7745
+ for (const markdownPath of markdownPaths) {
7746
+ const markdown = await fsPromises2.readFile(markdownPath, "utf8");
7747
+ const markdownDir = path7.dirname(markdownPath);
7748
+ const result = copyMarkdownAssets({
7749
+ markdown,
7750
+ markdownDir,
7751
+ allowMissing: this.options.allowMissingAssets,
7752
+ ...target(markdownDir)
7753
+ });
7754
+ if (result.copiedCount > 0 || result.missingCount > 0) {
7755
+ await this.deps.writeFile(markdownPath, result.markdown);
7756
+ }
7757
+ }
7758
+ }
7747
7759
  /**
7748
7760
  * Whether any output is colocated — the global mode, or any per-rule mode.
7749
7761
  * A colocated rule under a global aggregated mode still writes per-file