Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support caching results on Win32-based systems #832

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

dbehmoaras
Copy link

…ct creation

@dbehmoaras dbehmoaras changed the title added isWindows check, support resolving windows paths for cache obje… Support caching results on Win32-based systems Nov 12, 2024
@webpro
Copy link
Collaborator

webpro commented Nov 12, 2024

Thanks for your PR, @dbehmoaras! This is the central function to normalize paths to posix format. So I'm not sure whether this is the right location to fix the issue. What's the exact issue you're trying to solve here?

@dbehmoaras
Copy link
Author

dbehmoaras commented Nov 12, 2024

Thanks for your PR, @dbehmoaras! This is the central function to normalize paths to posix format. So I'm not sure whether this is the right location to fix the issue. What's the exact issue you're trying to solve here?

Hmm - I see your point. Maybe then it should be addressed in file that handles the caching of the results ? The issue we run into is that Knip fails to update the cache on windows systems because it resolves a posix file path when windows env expects a win32 path from node.js - see permalink below:

this.filePath = isAbsolute(_path) ? resolve(_path, cacheId) : resolve(cwd, _path, cacheId);

Is there a separate file that handles win32 file paths ? Open to any approach

@webpro
Copy link
Collaborator

webpro commented Nov 12, 2024

Alright, clear.

Maybe you can import path from 'node:path in file-entry-cache.ts and take it from there? Fix this.filePath with path.resolve, etc.

@dbehmoaras
Copy link
Author

Ok let me try that

@webpro
Copy link
Collaborator

webpro commented Nov 12, 2024

Great, I'm asking so you can directly test it works properly on Windows. If you update the PR, you will automatically get a new version that you can npm install anywhere, if that helps.

Copy link

pkg-pr-new bot commented Nov 12, 2024

Open in Stackblitz

bun add https://pkg.pr.new/knip@832

commit: 473ba49

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.

2 participants