executable-stories-formatters 1.17.0 → 1.17.1

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/cli.js CHANGED
@@ -9187,27 +9187,39 @@ var ReportGenerator = class {
9187
9187
  bundleAssets(htmlPath, { allowMissing: this.options.allowMissingAssets });
9188
9188
  }
9189
9189
  }
9190
- const astroPaths = results.get("astro-markdown");
9191
- if (astroPaths) {
9192
- for (const mdPath of astroPaths) {
9193
- const content = await fsPromises2.readFile(mdPath, "utf8");
9194
- const mdDir = path14.dirname(mdPath);
9195
- const assetsDir = path14.resolve(this.options.astro.assetsDir);
9196
- const result = copyMarkdownAssets({
9197
- markdown: content,
9198
- markdownDir: mdDir,
9199
- assetsDir,
9200
- assetsBaseUrl: this.options.astro.assetsBaseUrl,
9201
- allowMissing: this.options.allowMissingAssets
9202
- });
9203
- if (result.copiedCount > 0 || result.missingCount > 0) {
9204
- await this.deps.writeFile(mdPath, result.markdown);
9205
- }
9206
- }
9207
- }
9190
+ await this.bundleMarkdownAssets(results.get("markdown"), (markdownDir) => ({
9191
+ assetsDir: path14.join(markdownDir, "assets"),
9192
+ assetsBaseUrl: "assets"
9193
+ }));
9194
+ await this.bundleMarkdownAssets(results.get("astro-markdown"), () => ({
9195
+ // assetsDir is resolved from CWD (same as outputDir), not relative to outputDir
9196
+ assetsDir: path14.resolve(this.options.astro.assetsDir),
9197
+ assetsBaseUrl: this.options.astro.assetsBaseUrl
9198
+ }));
9208
9199
  }
9209
9200
  return results;
9210
9201
  }
9202
+ /**
9203
+ * Copy every local asset these markdown reports reference into an assets
9204
+ * directory and rewrite the refs. The destination is computed per report
9205
+ * because colocated output writes one per source file.
9206
+ */
9207
+ async bundleMarkdownAssets(markdownPaths, target) {
9208
+ if (!markdownPaths) return;
9209
+ for (const markdownPath of markdownPaths) {
9210
+ const markdown = await fsPromises2.readFile(markdownPath, "utf8");
9211
+ const markdownDir = path14.dirname(markdownPath);
9212
+ const result = copyMarkdownAssets({
9213
+ markdown,
9214
+ markdownDir,
9215
+ allowMissing: this.options.allowMissingAssets,
9216
+ ...target(markdownDir)
9217
+ });
9218
+ if (result.copiedCount > 0 || result.missingCount > 0) {
9219
+ await this.deps.writeFile(markdownPath, result.markdown);
9220
+ }
9221
+ }
9222
+ }
9211
9223
  /**
9212
9224
  * Whether any output is colocated — the global mode, or any per-rule mode.
9213
9225
  * A colocated rule under a global aggregated mode still writes per-file