Skip to content

Commit 68a4125

Browse files
committed
Do not delete whole of cache dir.
Previous buildpacks may have files installed in cache dir. Clearing out the whole cache will mean removing those files too. We will only clear out cache contents that our buildpack installed.
1 parent 2cf5ff1 commit 68a4125

File tree

2 files changed

+7
-6
lines changed

2 files changed

+7
-6
lines changed

bin/compile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,9 @@ heroku_dir=$build_dir/.heroku
2222
source ${build_pack_dir}/lib/common.sh
2323
source ${build_pack_dir}/lib/build.sh
2424

25-
load_previous_npm_node_versions
2625

2726
head "Loading configuration and environment"
27+
load_previous_npm_node_versions
2828
load_config
2929
export_config_vars
3030
export_mix_env

lib/build.sh

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
cleanup_cache() {
2-
if [ $clean_cache ]; then
3-
info "`clean_cache` option set to true."
2+
if [ $clean_cache = true ]; then
3+
info "clean_cache option set to true."
44
info "Cleaning out cache contents"
5-
rm -rf $cache_dir/*
5+
rm -rf $cache_dir/npm-version
6+
rm -rf $cache_dir/node-version
7+
cleanup_old_node
68
fi
79
}
810

@@ -21,7 +23,6 @@ download_node() {
2123
if [ ! -f ${cached_node} ]; then
2224
info "Downloading node ${node_version}..."
2325
curl -s ${node_url} -o ${cached_node}
24-
cleanup_old_node
2526
else
2627
info "Using cached node ${node_version}..."
2728
fi
@@ -33,7 +34,7 @@ cleanup_old_node() {
3334
# Note that $old_node will have a format of "v5.5.0" while $node_version
3435
# has the format "5.6.0"
3536

36-
if [ $old_node != v$node_version ] && [ -f $old_node_dir ]; then
37+
if [ $clean_cache = true ] || [ $old_node != v$node_version ] && [ -f $old_node_dir ]; then
3738
info "Cleaning up old Node $old_node and old dependencies in cache"
3839
rm $old_node_dir
3940
rm -rf $cache_dir/node_modules

0 commit comments

Comments
 (0)