Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in
Toggle navigation
H
heroku-buildpack-nodejs
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
JIRA
JIRA
Merge Requests
0
Merge Requests
0
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Python-Dev
heroku-buildpack-nodejs
Commits
03c80359
Commit
03c80359
authored
Dec 17, 2014
by
Hunter Loftis
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
renamed DISABLE_BUILD_CACHE to NODE_MODULES_CACHE
parent
68e00a84
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
26 additions
and
55 deletions
+26
-55
README.md
README.md
+10
-10
compile
bin/compile
+12
-9
test
bin/test
+4
-4
README.md
test/disable-build-cache-1/README.md
+0
-1
package.json
test/disable-build-cache-1/package.json
+0
-15
README.md
test/disable-build-cache-2/README.md
+0
-1
package.json
test/disable-build-cache-2/package.json
+0
-15
No files found.
README.md
View file @
03c80359
...
@@ -69,21 +69,21 @@ Default: the version of npm bundled with your node install (varies).
...
@@ -69,21 +69,21 @@ Default: the version of npm bundled with your node install (varies).
### Enable or disable node_modules caching
### Enable or disable node_modules caching
Sometimes it's necessary to be able to build without any cache present.
For a 'clean' build without using any cached node modules:
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.
```
shell
```
shell
heroku config:set
DISABLE_BUILD_CACHE
=
tru
e
heroku config:set
NODE_MODULES_CACHE
=
fals
e
git commit
-am
'build'
--allow-empty
git commit
-am
'
re
build'
--allow-empty
git push heroku master
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
### Enable or disable devDependencies installation
...
...
bin/compile
View file @
03c80359
...
@@ -33,7 +33,7 @@ trap build_failed ERR
...
@@ -33,7 +33,7 @@ trap build_failed ERR
# Load config vars into environment; start with defaults
# Load config vars into environment; start with defaults
export
NPM_CONFIG_PRODUCTION
=
true
export
NPM_CONFIG_PRODUCTION
=
true
export
DISABLE_BUILD_CACHE
=
fals
e
export
NODE_MODULES_CACHE
=
tru
e
if
[
-d
"
$env_dir
"
]
;
then
if
[
-d
"
$env_dir
"
]
;
then
export_env_dir
$env_dir
export_env_dir
$env_dir
...
@@ -81,7 +81,7 @@ info "node_modules cached: $modules_cached"
...
@@ -81,7 +81,7 @@ info "node_modules cached: $modules_cached"
echo
""
echo
""
printenv
|
grep
^NPM_CONFIG_ | indent
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
source
$bp_dir
/bin/warnings.sh
...
@@ -124,18 +124,21 @@ head "Building dependencies"
...
@@ -124,18 +124,21 @@ head "Building dependencies"
# Did we bust the cache?
# Did we bust the cache?
if
!
$modules_cached
;
then
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
elif
[
"
$node_previous
"
!=
""
]
&&
[
"
$node_engine
"
!=
"
$node_previous
"
]
;
then
info
"Node version changed (
$node_previous
=>
$node_engine
); invalidating cache"
info
"Node version changed (
$node_previous
=>
$node_engine
); invalidating cache"
cache_busted
=
tru
e
use_cache
=
fals
e
elif
[
"
$npm_previous
"
!=
""
]
&&
[
"
$npm_engine
"
!=
"
$npm_previous
"
]
;
then
elif
[
"
$npm_previous
"
!=
""
]
&&
[
"
$npm_engine
"
!=
"
$npm_previous
"
]
;
then
info
"Npm version changed (
$npm_previous
=>
$npm_engine
); invalidating cache"
info
"Npm version changed (
$npm_previous
=>
$npm_engine
); invalidating cache"
cache_busted
=
tru
e
use_cache
=
fals
e
elif
[
"
$bp_version
"
!=
"
$bp_previous
"
]
;
then
elif
[
"
$bp_version
"
!=
"
$bp_previous
"
]
;
then
info
"New buidpack version (
$bp_version
); invalidating cache"
info
"New bui
l
dpack version (
$bp_version
); invalidating cache"
cache_busted
=
tru
e
use_cache
=
fals
e
else
else
cache_busted
=
fals
e
use_cache
=
tru
e
fi
fi
if
[
"
$modules_source
"
==
""
]
;
then
if
[
"
$modules_source
"
==
""
]
;
then
...
@@ -145,7 +148,7 @@ elif [ $modules_source == "prebuilt" ]; then
...
@@ -145,7 +148,7 @@ elif [ $modules_source == "prebuilt" ]; then
info
"Rebuilding any native modules for this architecture"
info
"Rebuilding any native modules for this architecture"
npm rebuild 2>&1
npm rebuild 2>&1
elif
!
$DISABLE_BUILD_CACHE
&&
!
$cache_busted
;
then
elif
$use_cache
;
then
info
"Restoring node modules from cache"
info
"Restoring node modules from cache"
cp
-r
$cache_dir
/node/node_modules
$build_dir
/
cp
-r
$cache_dir
/node/node_modules
$build_dir
/
info
"Pruning unused dependencies"
info
"Pruning unused dependencies"
...
...
bin/test
View file @
03c80359
...
@@ -218,16 +218,16 @@ testDisableCache() {
...
@@ -218,16 +218,16 @@ testDisableCache() {
cache
=
$(
mktmpdir
)
cache
=
$(
mktmpdir
)
env_dir
=
$(
mktmpdir
)
env_dir
=
$(
mktmpdir
)
compile
"
disable-build
-cache-1"
$cache
compile
"
node-modules
-cache-1"
$cache
assertCaptured
"lodash@1.0.0"
assertCaptured
"lodash@1.0.0"
assertCapturedSuccess
assertCapturedSuccess
compile
"
disable-build
-cache-2"
$cache
compile
"
node-modules
-cache-2"
$cache
assertCaptured
"lodash@1.0.0"
assertCaptured
"lodash@1.0.0"
assertCapturedSuccess
assertCapturedSuccess
echo
"
true"
>
$env_dir
/DISABLE_BUILD
_CACHE
echo
"
false"
>
$env_dir
/NODE_MODULES
_CACHE
compile
"
disable-build
-cache-2"
$cache
$env_dir
compile
"
node-modules
-cache-2"
$cache
$env_dir
assertCaptured
"lodash@1.3.1"
assertCaptured
"lodash@1.3.1"
assertCapturedSuccess
assertCapturedSuccess
}
}
...
...
test/disable-build-cache-1/README.md
deleted
100644 → 0
View file @
68e00a84
A fake README, to keep npm from polluting stderr.
\ No newline at end of file
test/disable-build-cache-1/package.json
deleted
100644 → 0
View file @
68e00a84
{
"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"
}
}
test/disable-build-cache-2/README.md
deleted
100644 → 0
View file @
68e00a84
A fake README, to keep npm from polluting stderr.
\ No newline at end of file
test/disable-build-cache-2/package.json
deleted
100644 → 0
View file @
68e00a84
{
"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"
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment