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

Make node index cache aware of the cached URL #717

Merged
merged 1 commit into from
Apr 30, 2020

Conversation

charlespierce
Copy link
Contributor

Closes #242

Info

  • The current cache of the Node index is global and doesn't know about the fact that hooks can affect the URL we check for the Node index.
  • This means that if you create the cache using the public repo, but then switch to a project that has hooks pointing to a private repo, the cache used will still be that of the public repo.
  • Problems can arise when a private repo has a subset of the publicly available versions of Node, because the cache could result in us writing an invalid Node version into package.json, even though the project is correctly configured with Volta hooks.

Changes

  • Updated the cache format to include the URL that was fetched as the first line, followed by the contents.
  • Updated the function that reads the cache to check for the URL at the start and only return the contents if the cached URL matches the requested URL.
  • Added debug output of whether or not the cache was used.

Tested

  • Local testing to confirm that switching between a project with hooks and the public repo results in the cache resetting, while staying in a single context means the cache is used.

Copy link
Contributor

@chriskrycho chriskrycho left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@chriskrycho chriskrycho merged commit 6195e4c into volta-cli:master Apr 30, 2020
@charlespierce charlespierce deleted the url_aware_cache branch April 30, 2020 18:59
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.

Make Cache of Node Index URL Aware
2 participants