You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
fix: preserve YAML inline comments when updating deps
🐛 **Critical Fix:** YAML comments are now preserved during dependency updates
**Problem:**
When updating dependencies in YAML files, inline comments were being stripped:
- Before: \`node: ^22.12.0 # only temporarily needed until bun & vue-tsc issue is resolved\`
- After: \`node: ^22.17.1\` ❌ (comment lost)
**Root Cause:**
The regex pattern \`([^\\n\\r]*)\` captured everything after the colon, including
comments, then replaced the entire match with just the version number.
**Solution:**
Enhanced regex to capture three distinct parts:
1. \`(\\s*\\bpackage\\b\\s*:\\s*)\` - package name and colon
2. \`([^\\s#\\n\\r]+)\` - version part only (stops at whitespace or #)
3. \`(\\s*#.*)?\` - optional comment part
Replacement now preserves: \`package + colon + new version + original comment\`
**Regex Changes:**
- Old: \`package: version-and-comment-together\` → \`package: new-version\` ❌
- New: \`package: version # comment\` → \`package: new-version # comment\` ✅
**Test Coverage:**
- ✅ Single dependency with comment preservation
- ✅ Multiple dependencies with mixed comments
- ✅ Dependencies without comments (no change)
- ✅ Full-line comments remain untouched
- ✅ All existing constraint preservation tests still pass
**Real-world Impact:**
✅ \`node: ^22.12.0 # only temporarily needed until bun & vue-tsc issue is resolved\`
✅ Updates to: \`node: ^22.17.1 # only temporarily needed until bun & vue-tsc issue is resolved\`
No more losing valuable context information in dependency files
0 commit comments