Commit 03c80359 authored by Hunter Loftis's avatar Hunter Loftis

renamed DISABLE_BUILD_CACHE to NODE_MODULES_CACHE

parent 68e00a84
......@@ -69,21 +69,21 @@ Default: the version of npm bundled with your node install (varies).
### Enable or disable node_modules caching
Sometimes it's necessary to be able to build without any cache present.
Caching node_modules between builds can dramatically speed up build times.
However, `npm install` doesn't automatically update already installed modules
as long as they fall within acceptable semver ranges,
which can lead to outdated modules.
For a 'clean' build without using any cached node modules:
```shell
heroku config:set DISABLE_BUILD_CACHE=true
git commit -am 'build' --allow-empty
heroku config:set NODE_MODULES_CACHE=false
git commit -am 'rebuild' --allow-empty
git push heroku master
heroku config:unset DISABLE_BUILD_CACHE
heroku config:unset NODE_MODULES_CACHE
```
Default: `DISABLE_BUILD_CACHE` defaults to false
Caching node_modules between builds dramatically speeds up build times.
However, `npm install` doesn't automatically update already-installed modules
as long as they fall within acceptable semver ranges,
which can lead to outdated modules.
Default: `NODE_MODULES_CACHE` defaults to true
### Enable or disable devDependencies installation
......
......@@ -33,7 +33,7 @@ trap build_failed ERR
# Load config vars into environment; start with defaults
export NPM_CONFIG_PRODUCTION=true
export DISABLE_BUILD_CACHE=false
export NODE_MODULES_CACHE=true
if [ -d "$env_dir" ]; then
export_env_dir $env_dir
......@@ -81,7 +81,7 @@ info "node_modules cached: $modules_cached"
echo ""
printenv | grep ^NPM_CONFIG_ | indent
info "DISABLE_BUILD_CACHE=$DISABLE_BUILD_CACHE"
info "NODE_MODULES_CACHE=$NODE_MODULES_CACHE"
source $bp_dir/bin/warnings.sh
......@@ -124,18 +124,21 @@ head "Building dependencies"
# Did we bust the cache?
if ! $modules_cached; then
cache_busted=true
use_cache=false
elif ! $NODE_MODULES_CACHE; then
info "Cache disabled with NODE_MODULES_CACHE"
use_cache=false
elif [ "$node_previous" != "" ] && [ "$node_engine" != "$node_previous" ]; then
info "Node version changed ($node_previous => $node_engine); invalidating cache"
cache_busted=true
use_cache=false
elif [ "$npm_previous" != "" ] && [ "$npm_engine" != "$npm_previous" ]; then
info "Npm version changed ($npm_previous => $npm_engine); invalidating cache"
cache_busted=true
use_cache=false
elif [ "$bp_version" != "$bp_previous" ]; then
info "New buidpack version ($bp_version); invalidating cache"
cache_busted=true
info "New buildpack version ($bp_version); invalidating cache"
use_cache=false
else
cache_busted=false
use_cache=true
fi
if [ "$modules_source" == "" ]; then
......@@ -145,7 +148,7 @@ elif [ $modules_source == "prebuilt" ]; then
info "Rebuilding any native modules for this architecture"
npm rebuild 2>&1
elif ! $DISABLE_BUILD_CACHE && ! $cache_busted; then
elif $use_cache; then
info "Restoring node modules from cache"
cp -r $cache_dir/node/node_modules $build_dir/
info "Pruning unused dependencies"
......
......@@ -218,16 +218,16 @@ testDisableCache() {
cache=$(mktmpdir)
env_dir=$(mktmpdir)
compile "disable-build-cache-1" $cache
compile "node-modules-cache-1" $cache
assertCaptured "lodash@1.0.0"
assertCapturedSuccess
compile "disable-build-cache-2" $cache
compile "node-modules-cache-2" $cache
assertCaptured "lodash@1.0.0"
assertCapturedSuccess
echo "true" > $env_dir/DISABLE_BUILD_CACHE
compile "disable-build-cache-2" $cache $env_dir
echo "false" > $env_dir/NODE_MODULES_CACHE
compile "node-modules-cache-2" $cache $env_dir
assertCaptured "lodash@1.3.1"
assertCapturedSuccess
}
......
A fake README, to keep npm from polluting stderr.
\ No newline at end of file
{
"name": "node-buildpack-test-app",
"version": "0.0.1",
"description": "node buildpack integration test app",
"repository": {
"type": "git",
"url": "http://github.com/example/example.git"
},
"dependencies": {
"lodash": "1.0.0"
},
"engines": {
"node": "~0.10.0"
}
}
A fake README, to keep npm from polluting stderr.
\ No newline at end of file
{
"name": "node-buildpack-test-app",
"version": "0.0.1",
"description": "node buildpack integration test app",
"repository": {
"type": "git",
"url": "http://github.com/example/example.git"
},
"dependencies": {
"lodash": "^1.0.0"
},
"engines": {
"node": "~0.10.0"
}
}
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