Commit 630c1caa authored by Hunter Loftis's avatar Hunter Loftis

Merge pull request #183 from heroku/store-node-version

avoid updating node_engine state
parents a77cd257 3ec73e1b
...@@ -55,11 +55,10 @@ warn_node_modules "$modules_source" ...@@ -55,11 +55,10 @@ warn_node_modules "$modules_source"
head "Installing binaries" head "Installing binaries"
if [ "$iojs_engine" == "" ]; then if [ "$iojs_engine" == "" ]; then
install_node install_node "$node_engine"
else else
install_iojs install_iojs "$iojs_engine"
fi fi
node_engine=`node --version`
install_npm install_npm
####### Build the project's dependencies ####### Build the project's dependencies
......
...@@ -72,6 +72,8 @@ show_current_state() { ...@@ -72,6 +72,8 @@ show_current_state() {
} }
install_node() { install_node() {
local node_engine=$1
# Resolve non-specific node versions using semver.herokuapp.com # Resolve non-specific node versions using semver.herokuapp.com
if ! [[ "$node_engine" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then if ! [[ "$node_engine" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
info "Resolving node version ${node_engine:-(latest stable)} via semver.io..." info "Resolving node version ${node_engine:-(latest stable)} via semver.io..."
...@@ -90,8 +92,10 @@ install_node() { ...@@ -90,8 +92,10 @@ install_node() {
} }
install_iojs() { install_iojs() {
local iojs_engine=$1
# Resolve non-specific iojs versions using semver.herokuapp.com # Resolve non-specific iojs versions using semver.herokuapp.com
if ! [[ "$node_engine" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then if ! [[ "$iojs_engine" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
info "Resolving iojs version ${iojs_engine:-(latest stable)} via semver.io..." info "Resolving iojs version ${iojs_engine:-(latest stable)} via semver.io..."
iojs_engine=$(curl --silent --get --data-urlencode "range=${iojs_engine}" https://semver.herokuapp.com/iojs/resolve) iojs_engine=$(curl --silent --get --data-urlencode "range=${iojs_engine}" https://semver.herokuapp.com/iojs/resolve)
fi fi
...@@ -126,21 +130,6 @@ install_npm() { ...@@ -126,21 +130,6 @@ install_npm() {
fi fi
} }
get_cache_status() {
# Did we bust the cache?
if ! $modules_cached; then
echo "No cache available"
elif ! $NODE_MODULES_CACHE; then
echo "Cache disabled with NODE_MODULES_CACHE"
elif [ "$node_previous" != "" ] && [ "$node_engine" != "$node_previous" ]; then
echo "Node version changed ($node_previous => $node_engine); invalidating cache"
elif [ "$npm_previous" != "" ] && [ "$npm_engine" != "$npm_previous" ]; then
echo "Npm version changed ($npm_previous => $npm_engine); invalidating cache"
else
echo "valid"
fi
}
ensure_procfile() { ensure_procfile() {
local start_method=$1 local start_method=$1
local build_dir=$2 local build_dir=$2
...@@ -176,20 +165,40 @@ clean_npm() { ...@@ -176,20 +165,40 @@ clean_npm() {
rm -rf "$build_dir/.npm" rm -rf "$build_dir/.npm"
} }
clean_cache() { # Caching
info "Cleaning previous cache"
rm -rf "$cache_dir/node_modules" # (for apps still on the older caching strategy)
rm -rf "$cache_dir/node"
}
create_cache() { create_cache() {
info "Caching results for future builds" info "Caching results for future builds"
mkdir -p $cache_dir/node mkdir -p $cache_dir/node
echo $node_engine > $cache_dir/node/node-version echo `node --version` > $cache_dir/node/node-version
echo $npm_engine > $cache_dir/node/npm-version echo `npm --version` > $cache_dir/node/npm-version
if test -d $build_dir/node_modules; then if test -d $build_dir/node_modules; then
cp -r $build_dir/node_modules $cache_dir/node cp -r $build_dir/node_modules $cache_dir/node
fi fi
} }
clean_cache() {
info "Cleaning previous cache"
rm -rf "$cache_dir/node_modules" # (for apps still on the older caching strategy)
rm -rf "$cache_dir/node"
}
get_cache_status() {
local node_version=`node --version`
local npm_version=`npm --version`
# Did we bust the cache?
if ! $modules_cached; then
echo "No cache available"
elif ! $NODE_MODULES_CACHE; then
echo "Cache disabled with NODE_MODULES_CACHE"
elif [ "$node_previous" != "" ] && [ "$node_version" != "$node_previous" ]; then
echo "Node version changed ($node_previous => $node_version); invalidating cache"
elif [ "$npm_previous" != "" ] && [ "$npm_version" != "$npm_previous" ]; then
echo "Npm version changed ($npm_previous => $npm_version); invalidating cache"
else
echo "valid"
fi
}
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