Fix ignore pattern handling#3
Conversation
Adds a repeatable --ignore CLI option and support for ~/.config/dev-purge/config.json with an ignore array. Patterns are glob-like (supports ~ and **). Scanner respects ignore patterns when discovering projects and bloat dirs. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
|
Nice fix, ship after one tweak. Notes: P1 — P2 — Move config read inside P2 — Guard empty pattern after P3 — Warn on invalid config entries P3 — Note case-sensitivity in README Nice catches in this PR
LGTM after P1. |
- Make getFlagValue/getFlagValues/positional parsing consistent via a known-flag check, so an ignore value that starts with "-" (e.g. `--ignore -skip`) is captured instead of silently dropped, and a real flag after `--ignore` (e.g. `--ignore --json`) is not swallowed. (P1) - Defer the config.json read into a runtime loadIgnorePatterns() so a slow or hung $XDG_CONFIG_HOME mount can no longer hang `dev-purge --help`. (P2) - Warn on invalid (non-string/empty) config "ignore" entries instead of dropping them silently — predictable behavior for cron-driven runs. (P3) - Guard against a bare "~" expanding to "" in envs with no HOME, which would otherwise compile to a match-everything pattern. (P2) - README: note case-sensitivity of bare-name matching and config validation. (P3) Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
|
Thanks for the thorough review — all points addressed in P1 —
P2 — Defer config read out of module top-level ✅ P2 — Guard empty pattern after P3 — Warn on invalid config entries ✅ P3 — README case-sensitivity note ✅ Re #2: I'm rebasing that PR on top of this one and dropping its duplicated glob/ignore logic so there's a single implementation — details to follow on that PR. Ready for another look here. |
Adds best-effort cleanup of Docker leftovers alongside the filesystem scan: exited containers (status=exited) and dangling images (dangling=true) only — running containers and tagged images are never targeted. Docker is invoked via execFile with an argv array (no shell) with a 15s timeout. New surface: - `--containers-only` / `--images-only` (mutually exclusive) and `--category containers` / `--category images` to scope to runtime artifacts; runtime-only modes skip the filesystem walk entirely. - `--older-than` is applied to dated artifacts; artifacts with no parseable creation date are kept (safe choice) with a warning explaining why. - Per-item delete with separate success/failure tracking. Rebased on top of LarsenCundric#3 (ignore-pattern handling) so there is a single glob/ignore implementation: the duplicated `globToRegExp`, `--ignore`/config loading, and `canCollectBloatAtDir` root-bloat fix that an earlier version of this branch carried are dropped and inherited from LarsenCundric#3 instead. Review fixes: - error when --containers-only and --images-only are combined - warn (don't silently drop) on unparseable Docker JSON output lines - warn when --older-than keeps an artifact due to an unparseable date - show the real Docker error dimmed when runtime cleanup is skipped - combined early-return so runtime-only runs print/act correctly Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
|
@LarsenCundric — this is step 1 in the order below. Ready to merge + ship 🚀Both PRs are MERGEABLE / CLEAN and all review feedback is addressed. Since I only have read access here, the merge + publish are yours to do. Suggested order: No release CI is configured, so step 3–4 are a manual publish by the npm package owner. Happy to prep the version bump as a separate PR if you’d prefer that to be in git first. |
Summary
--ignoreglob handling so patterns like~/.vscode-server/**are parsed safely~,*,?, and**--ignoreusage and config support in the READMEdev-purgeinside a projectWhy this is needed
I run
dev-purgefrom a cron job, so ignore rules need to be reliable and non-interactive-safe. If an ignore pattern from CLI/config is malformed, unsupported, or interpreted too narrowly, the scheduled cleanup can either scan paths that should be excluded or fail unexpectedly. This makes folder exclusion predictable for automated runs.Ignore examples now supported
dev-purge --ignore node_modules dev-purge --ignore ./legacy-app dev-purge --ignore '~/Library/Caches/**'Config file:
{ ignore: [~/.vscode-server/**, ./vendor] }Checks
node --check src/scanner.jsnode --check src/index.jsnpm start -- --dry-run --depth 0 -s 0 --ignore node_modulesexcludes rootnode_modules