Skip to content

Commit

Permalink
Do not delete whole of cache dir.
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
gjaldon committed Aug 7, 2016
1 parent 2cf5ff1 commit 68a4125
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
2 changes: 1 addition & 1 deletion bin/compile
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@ heroku_dir=$build_dir/.heroku
source ${build_pack_dir}/lib/common.sh
source ${build_pack_dir}/lib/build.sh

load_previous_npm_node_versions

head "Loading configuration and environment"
load_previous_npm_node_versions
load_config
export_config_vars
export_mix_env
Expand Down
11 changes: 6 additions & 5 deletions lib/build.sh
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
cleanup_cache() {
if [ $clean_cache ]; then
info "`clean_cache` option set to true."
if [ $clean_cache = true ]; then
info "clean_cache option set to true."
info "Cleaning out cache contents"
rm -rf $cache_dir/*
rm -rf $cache_dir/npm-version
rm -rf $cache_dir/node-version
cleanup_old_node
fi
}

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

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

0 comments on commit 68a4125

Please sign in to comment.