feat: add --target flag to filter target files - #95
Merged
Conversation
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.
Duncanma
approved these changes
Jul 29, 2026
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
--target <glob>CLI flag to restrict which target files snipsync processesnpx snipsync --target "docs/develop/dotnet/**/*.mdx"globdependencyPerformance
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.
--targetsingle fileThe 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 filenpx snipsync --target "docs/develop/dotnet/**/*.mdx"processes all matching filesnpx snipsync(no flag) processes all files as beforenpx snipsync --clearstill works