fix: address code review feedback for node-finder

- Fix PATH collision detection using proper path segment matching
  instead of substring includes() which could cause false positives
- Reorder fnm Windows paths to prioritize canonical installation path
  over shell shims (fnm_multishells)
- Make Windows path test platform-aware since path.dirname handles
  backslash paths differently on non-Windows systems

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
Kacper
2025-12-21 14:49:19 +01:00
parent 49f04cf403
commit d3005393df
2 changed files with 17 additions and 5 deletions

View File

@@ -96,12 +96,21 @@ describe('node-finder', () => {
});
it('should handle Windows-style paths', () => {
// On Windows, path.dirname recognizes backslash paths
// On other platforms, backslash is not a path separator
const nodePath = 'C:\\Program Files\\nodejs\\node.exe';
const currentPath = 'C:\\Windows\\System32';
const result = buildEnhancedPath(nodePath, currentPath);
expect(result).toBe(`C:\\Program Files\\nodejs${delimiter}${currentPath}`);
if (process.platform === 'win32') {
// On Windows, should prepend the node directory
expect(result).toBe(`C:\\Program Files\\nodejs${delimiter}${currentPath}`);
} else {
// On non-Windows, backslash paths are treated as relative paths
// path.dirname returns '.' so the function returns currentPath unchanged
expect(result).toBe(currentPath);
}
});
it('should use default empty string for currentPath', () => {