Skip to content

Conversation

@harshrajdubey
Copy link

Fix Windows case sensitivity issue with npm query -C option

This PR resolves a critical Windows compatibility issue where npm query .workspace -C "path" fails when the specified path has different case than the actual filesystem path. The issue affects both drive letter case (C: vs c:) and folder name case (CLI vs cli).

What this fixes:

  • Drive letter normalization: Ensures npm query .workspace -C "c:\project" works the same as npm query .workspace -C "C:\project"
  • Folder name case handling: Makes npm query .workspace -C "d:\hrd\CLI" work when the actual folder is named cli
  • Workspace selector matching: The :path() selector now performs case-insensitive matching on Windows
  • Cache key consistency: Arborist cache keys are now case-insensitive on Windows to prevent cache misses

How it works:

  1. Config validation layer: Drive letters are normalized to uppercase in workspaces/config/lib/type-defs.js
  2. Path comparison layer: Relative path calculations use case-insensitive comparison in workspaces/arborist/lib/relpath.js
  3. Query selector layer: The :path() pseudo-selector handles Windows case sensitivity in workspaces/arborist/lib/query-selector-all.js
  4. Cache management layer: Smart cache key generation with filesystem fallback in workspaces/arborist/lib/arborist/load-actual.js

Testing:

  • All existing tests pass (102 suites, 4807 assertions)
  • 100% code coverage maintained
  • Manual testing confirms all case variations work correctly

References

Fixes #8510

@harshrajdubey harshrajdubey requested a review from a team as a code owner September 5, 2025 08:05
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.

[BUG] npm query failing on Windows with case insensitive paths

1 participant