Skip to content

fix(convert): resolve directory pruning failure on Windows due to pat…#148

Open
Adityakk9031 wants to merge 2 commits into
inthhq:mainfrom
Adityakk9031:#146
Open

fix(convert): resolve directory pruning failure on Windows due to pat…#148
Adityakk9031 wants to merge 2 commits into
inthhq:mainfrom
Adityakk9031:#146

Conversation

@Adityakk9031

@Adityakk9031 Adityakk9031 commented Jul 12, 2026

Copy link
Copy Markdown
Contributor

close:#146

Description

During output pruning (convertAllMdx --prune), empty parent directories left behind by deleted markdown files were not being deleted on Windows. This was caused by a path separator mismatch between glob output paths (which use /) and resolved output directories (which use \).

This PR normalizes all paths to platform-specific format using path.resolve() before performing prefix/directory matching.

Cause

In pruneOrphanedOutputs, the directory sweep checks if a parent directory is inside outDir using:

const resolvedOutDir = resolve(outDir); // uses backslashes on Windows
// ...
while (dir !== resolvedOutDir && dir.startsWith(resolvedOutDir + sep)) {

@coderabbitai

coderabbitai Bot commented Jul 12, 2026

Copy link
Copy Markdown

Warning

Review limit reached

@Adityakk9031, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 51 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: 8c9a7b6b-4122-4f96-b69f-5eeab1716e0e

📥 Commits

Reviewing files that changed from the base of the PR and between a89492a and ea63aa0.

📒 Files selected for processing (1)
  • packages/leadtype/src/convert/convert.ts
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ No new issues found.

Reviewed changes — a Windows-only fix in pruneOrphanedOutputs so that empty parent directories left by pruned .md files are actually removed.

  • Normalize parent paths before the prefix checkorphans are produced by fast-glob, which returns POSIX forward-slash paths on every platform, while resolve(outDir) returns backslash paths on Windows. The old dir.startsWith(resolvedOutDir + sep) guard therefore never matched on Windows, so empty directories were never swept. Wrapping the parent derivation (resolve(dirname(filePath)) and the loop step resolve(dirname(dir))) normalizes to platform-native separators, restoring correct behavior.

The change is minimal and correct. One harmless redundancy worth noting for a future pass: after the first loop iteration dir is already resolved and dirname of a native path stays native, so the loop-step resolve() is a no-op — not worth changing on its own.

Pullfrog  | View workflow run | Using Claude Opus𝕏

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ No new issues found.

Reviewed changes — a one-line cleanup in pruneOrphanedOutputs that removes the redundant loop-step resolve() flagged by the prior review.

  • Drop redundant resolve() in the directory-sweep loop — the loop step is now dir = dirname(dir) instead of dir = resolve(dirname(dir)). Since the parents set is seeded with resolve(dirname(filePath)), dir starts as a platform-native path and dirname of a native path stays native, so the removed resolve() was a no-op. Behavior is unchanged and the Windows prefix check still holds.

Pullfrog  | View workflow run | Using Claude Opus𝕏

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.

1 participant