Skip to content

Commit

Permalink
Fix additional occurrence of yarn cache nesting (#987)
Browse files Browse the repository at this point in the history
* Fix additional occurrence of yarn cache nesting

* Delete any nested caches

* Add changelog note about cache restoration

* Fix comment typo
  • Loading branch information
joshwlewis authored Feb 16, 2022
1 parent 6c2109e commit f4e7ee2
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

## main

- Fix issue with nested yarn cache during cache restoration ([987](https://github.com/heroku/heroku-buildpack-nodejs/pull/987)
- Fix issue with nested yarn caches and cache growth ([#985](https://github.com/heroku/heroku-buildpack-nodejs/pull/985))

## v191 (2022-02-14)
Expand Down
8 changes: 8 additions & 0 deletions lib/cache.sh
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,15 @@ restore_default_cache_directories() {
if has_yarn_cache "$build_dir"; then
echo "- yarn cache is checked into source control and cannot be cached"
elif [[ -e "$cache_dir/node/cache/yarn" ]]; then
rm -rf "$yarn_cache_dir"
mv "$cache_dir/node/cache/yarn" "$yarn_cache_dir"
if [[ -d "$yarn_cache_dir/yarn" ]]; then
# Older versions of the buildpack may have created nested yarn caches.
# This will remove the nested cache. This correction may be removed in
# the near future.
meta_set "yarn_nested_cache" "true"
rm -rf "$yarn_cache_dir/yarn"
fi
echo "- yarn cache"
else
echo "- yarn cache (not cached - skipping)"
Expand Down

0 comments on commit f4e7ee2

Please sign in to comment.