MCPcopy Create free account
hub / github.com/compozy/agh / writeSubdirMetas

Function writeSubdirMetas

internal/cli/docpost/docpost.go:358–378  ·  view source on GitHub ↗

writeSubdirMetas walks dstDir and emits a meta.json in every subdirectory (never the root) listing its direct children alphabetically, with an optional leading "index" when an index.mdx is present.

(ctx context.Context, dstDir string)

Source from the content-addressed store, hash-verified

356// (never the root) listing its direct children alphabetically, with an
357// optional leading "index" when an index.mdx is present.
358func writeSubdirMetas(ctx context.Context, dstDir string) error {
359 return filepath.WalkDir(dstDir, func(p string, d fs.DirEntry, err error) error {
360 if err != nil {
361 return fmt.Errorf("docpost: walk %s: %w", p, err)
362 }
363 if err := ensureContext(ctx, fmt.Sprintf("write meta for %s", p)); err != nil {
364 return err
365 }
366 if !d.IsDir() {
367 return nil
368 }
369 rel, err := filepath.Rel(dstDir, p)
370 if err != nil {
371 return fmt.Errorf("docpost: relative path from %s to %s: %w", dstDir, p, err)
372 }
373 if rel == "." {
374 return nil // root is hand-maintained
375 }
376 return writeDirMeta(ctx, p)
377 })
378}
379
380func writeDirMeta(ctx context.Context, dir string) error {
381 if err := ensureContext(ctx, fmt.Sprintf("write meta for %s", dir)); err != nil {

Callers 1

ProcessFunction · 0.85

Calls 2

ensureContextFunction · 0.85
writeDirMetaFunction · 0.85

Tested by

no test coverage detected