Commit 29427c56 authored by zeke's avatar zeke

restore cache only if package.json and node version are unchanged

parent 01580e32
...@@ -60,15 +60,19 @@ else ...@@ -60,15 +60,19 @@ else
fi fi
fi fi
# Run subsequent node/npm commands from the build path
cd $build_dir
# Configure cache directories # Configure cache directories
cache_store_dir="$cache_dir/node_modules/$node_version" package_checksum=$(cat $build_dir/package.json | md5sum | awk '{print $1}')
cache_store_dir="$cache_dir/node_modules/$node_version/$package_checksum"
cache_target_dir="$build_dir/node_modules" cache_target_dir="$build_dir/node_modules"
cd $build_dir # Restore node_modules from cache if resolved node version and
# package.json match the previous build
# Restore node_modules from cache if package.json unchanged. if test -d $cache_store_dir; then
if test -d $cache_store_dir && diff $cache_store_dir/package.json $build_dir/package.json >/dev/null; then status "package.json and node version unchanged since last build"
status "package.json unchanged; restoring node_modules from cache" status "Restoring node_modules from cache"
if test -d $cache_target_dir; then if test -d $cache_target_dir; then
cp -r $cache_store_dir/* $cache_target_dir/ cp -r $cache_store_dir/* $cache_target_dir/
else else
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment