Skip to content

feat: add --target flag to filter target files - #95

Merged
lennessyy merged 3 commits into
mainfrom
feat/target-filter
Jul 29, 2026
Merged

feat: add --target flag to filter target files#95
lennessyy merged 3 commits into
mainfrom
feat/target-filter

Conversation

@lennessyy

Copy link
Copy Markdown
Contributor

Summary

  • Adds --target <glob> CLI flag to restrict which target files snipsync processes
  • Example: npx snipsync --target "docs/develop/dotnet/**/*.mdx"
  • Supports glob patterns via the existing glob dependency
  • All origin repos are still downloaded and snippets extracted, but the splice phase only iterates over matched files

Performance

The splice phase dominates runtime at ~70% of total time (iterating every snippet x every target file). Filtering to a single file reduces total runtime from ~77s to ~19s.

Scenario Time
Full run (617 files) ~77s
--target single file ~19s

The remaining ~19s is repo downloads + snippet extraction, which could be further optimized in a future PR.

Test plan

  • npx snipsync --target "docs/path/to/file.mdx" processes only that file
  • npx snipsync --target "docs/develop/dotnet/**/*.mdx" processes all matching files
  • npx snipsync (no flag) processes all files as before
  • npx snipsync --clear still works

npx snipsync --target "docs/develop/dotnet/**/*.mdx"

When --target is set, only matching files are scanned and spliced.
All origin repos are still downloaded and snippets extracted, but
the splice phase (which dominates runtime at ~70% of total) only
iterates over the filtered files.

For a single file, this reduces runtime from ~77s to ~19s.
Covers the glob form, that only the splice step is narrowed, and that
--clear accepts --target too. Records three behaviors that are easy to get
wrong: the glob resolves from the working directory, it replaces `targets`
rather than filtering it, and allowed_target_extensions still applies.
One test per behavior documented in the README: the glob narrows the
splice, it can reach files outside the configured targets,
allowed_target_extensions still applies on top of it, clear honors the
filter, and omitting the filter still walks every target.

Confirmed the assertions bite by disabling the filter branch in
getTargetFilesInfos: four of the five fail. The fifth is the no-filter
regression case, which passes either way by design.
@lennessyy
lennessyy merged commit 7cfb8e9 into main Jul 29, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants