Skip to content

Make node index cache aware of the cached URL - #717

Merged
chriskrycho merged 1 commit into
volta-cli:masterfrom
charlespierce:url_aware_cache
Apr 30, 2020
Merged

Make node index cache aware of the cached URL#717
chriskrycho merged 1 commit into
volta-cli:masterfrom
charlespierce:url_aware_cache

Conversation

@charlespierce

Copy link
Copy Markdown
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.

@chriskrycho chriskrycho left a comment

Copy link
Copy Markdown
Contributor

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