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
a0961870
Commit
a0961870
authored
Jan 22, 2014
by
David Zülke
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #95 from heroku/namespaced-cache
Namespaced caching and node runtime version tracking
parents
d2ca0c2c
1e46a9b9
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
28 additions
and
6 deletions
+28
-6
compile
bin/compile
+28
-6
No files found.
bin/compile
View file @
a0961870
...
...
@@ -61,12 +61,18 @@ if test -d $build_dir/node_modules; then
status
"Found existing node_modules directory; skipping cache"
status
"Rebuilding any native dependencies"
npm rebuild 2>&1 | indent
elif
test
-d
$cache_dir
/node_modules
;
then
elif
test
-d
$cache_dir
/node
/node
_modules
;
then
status
"Restoring node_modules directory from cache"
cp
-r
$cache_dir
/node_modules
$build_dir
/
cp
-r
$cache_dir
/node
/node
_modules
$build_dir
/
status
"Pruning cached dependencies not specified in package.json"
npm prune 2>&1 | indent
if
test
-f
$cache_dir
/node/.heroku/node-version
&&
[
$(
cat
$cache_dir
/node/.heroku/node-version
)
!=
"
$node_version
"
]
;
then
status
"Node version changed since last build; rebuilding dependencies"
npm rebuild 2>&1 | indent
fi
fi
# Scope config var availability only to `npm install`
...
...
@@ -81,10 +87,26 @@ fi
npm
install
--userconfig
$build_dir
/.npmrc
--production
2>&1 | indent
)
status
"Caching node_modules directory for future builds"
rm
-rf
$cache_dir
/node_modules
mkdir
-p
$cache_dir
test
-d
$build_dir
/node_modules
&&
cp
-r
$build_dir
/node_modules
$cache_dir
/
# Persist goodies like node-version in the slug
mkdir
-p
$build_dir
/.heroku
# Save resolved node version in the slug for later reference
echo
$node_version
>
$build_dir
/.heroku/node-version
# Purge node-related cached content, being careful not to purge the top-level
# cache, for the sake of heroku-buildpack-multi apps.
rm
-rf
$cache_dir
/node_modules
# (for apps still on the older caching strategy)
rm
-rf
$cache_dir
/node
mkdir
-p
$cache_dir
/node
# If app has a node_modules directory, cache it.
if
test
-d
$build_dir
/node_modules
;
then
status
"Caching node_modules directory for future builds"
cp
-r
$build_dir
/node_modules
$cache_dir
/node
fi
# Copy goodies to the cache
cp
-r
$build_dir
/.heroku
$cache_dir
/node
status
"Cleaning up node-gyp and npm artifacts"
rm
-rf
"
$build_dir
/.node-gyp"
...
...
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