Conversation
There was a problem hiding this comment.
Pull request overview
Updates the repo’s baseline-accept hereby task to clean up empty baseline directories left behind after accepting deletions, reducing noise when comparing baseline trees.
Changes:
- Added a helper to walk upward and remove empty directories after baseline deletions.
- Extended
baselineAcceptTaskto run the empty-directory cleanup for both local and reference baseline trees.
| let current = path.resolve(dir); | ||
| while (current !== resolvedRoot) { | ||
| try { | ||
| await fs.promises.rmdir(current); |
There was a problem hiding this comment.
fs.promises.rmdir() is deprecated in modern Node (repo targets Node >=20) and may start emitting warnings or be removed in future. Prefer fs.promises.rm(current, { recursive: false, ... }) (and consider using the same Windows retry behavior as rimraf) to remove empty directories without relying on rmdir.
| await fs.promises.rmdir(current); | |
| await fs.promises.rm(current, { recursive: false }); |
| async function removeEmptyDirsUp(dir, root) { | ||
| const resolvedRoot = path.resolve(root); | ||
| let current = path.resolve(dir); | ||
| while (current !== resolvedRoot) { | ||
| try { | ||
| await fs.promises.rmdir(current); | ||
| } | ||
| catch { | ||
| // Not empty or doesn't exist; stop walking up. | ||
| break; | ||
| } | ||
| current = path.dirname(current); | ||
| } |
There was a problem hiding this comment.
removeEmptyDirsUp assumes dir is within root, but it doesn't enforce that. If an unexpected path outside root is passed in (e.g. due to a bad glob result or future refactor), this could walk upward deleting unrelated empty directories until an error stops it. Consider guarding up front (e.g. ensure path.relative(resolvedRoot, current) doesn’t start with .. / isn’t absolute) and stopping when current leaves root or reaches filesystem root.
The empty dirs are pretty annoying sometimes when comparing. Just have the accept task delete them.