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
6cb3786a
Commit
6cb3786a
authored
Sep 14, 2013
by
zeke
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
cache node too
parent
29427c56
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
25 additions
and
27 deletions
+25
-27
compile
bin/compile
+23
-25
test
bin/test
+2
-2
No files found.
bin/compile
View file @
6cb3786a
#!/usr/bin/env bash
build_dir
=
$1
cache_dir
=
$2
cache_
base
dir
=
$2
bp_dir
=
$(
cd
$(
dirname
$0
)
;
cd
..
;
pwd
)
stable_version
=
"0.10.18"
...
...
@@ -51,10 +51,8 @@ else
# Use the latest one.
node_version
=
$(
echo
"
$satisfying_versions
"
|
tail
-n
1
)
if
test
$node_version
;
then
status
"Downloading and installing node v
$version
"
download_and_install_node
$node_version
else
# Bail if no matching version was found
if
!
test
$node_version
;
then
error
"node
${
requested_version
}
not found among available versions on nodejs.org/dist"
fi
fi
...
...
@@ -63,35 +61,35 @@ fi
# Run subsequent node/npm commands from the build path
cd
$build_dir
# Configure cache director
ies
# Configure cache director
y
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_dir
=
"
$cache_basedir
/
$node_version
/
$package_checksum
"
# Restore node_modules from cache if resolved node version and
# package.json match the previous build
if
test
-d
$cache_store_dir
;
then
# Restore from cache if node and package.json haven't changed
if
test
-d
$cache_dir
;
then
status
"package.json and node version unchanged since last build"
status
"Restoring node_modules from cache"
if
test
-d
$cache_target_dir
;
then
cp
-r
$cache_store_dir
/
*
$cache_target_dir
/
else
cp
-r
$cache_store_dir
$cache_target_dir
fi
status
"Restoring node v
$node_version
and node_modules from cache"
test
-d
$cache_dir
/node_modules
&&
cp
-r
$cache_dir
/node_modules
$build_dir
/
cp
-r
$cache_dir
/vendor/node
$build_dir
/vendor/
else
# Install dependencies anew
if
[
$stable_version
!=
$node_version
]
;
then
status
"Downloading and installing node v
$version
"
download_and_install_node
$node_version
fi
status
"Installing dependencies"
npm
install
--production
| indent
status
"Rebuilding dependencies"
npm rebuild | indent
fi
# Cache node_modules for future builds
if
test
-d
$cache_target_dir
;
then
status
"Caching node_modules for future builds"
rm
-rf
$cache_store_di
r
mkdir
-p
$(
dirname
$cache_store_dir
)
cp
-r
$
cache_target_dir
$cache_store_dir
status
"Caching node and node_modules for future builds"
rm
-rf
$cache_dir
mkdir
-p
$cache_dir
mkdir
-p
$cache_dir
/vendo
r
test
-d
$build_dir
/node_modules
&&
cp
-r
$build_dir
/node_modules
$cache_dir
/
cp
-r
$
build_dir
/vendor/node
$cache_dir
/vendor/
fi
# Update the PATH
...
...
bin/test
View file @
6cb3786a
...
...
@@ -47,8 +47,8 @@ testProfileCreated() {
testNodeModulesCached
()
{
cache
=
$(
mktmpdir
)
compile
"node-modules-caching"
$cache
assertCaptured
"Caching node
_modules for future builds
"
assertEquals
"1"
"
$(
ls
-1
$cache
/
node_modules/
0.10.18 |
wc
-l
)
"
assertCaptured
"Caching node"
assertEquals
"1"
"
$(
ls
-1
$cache
/0.10.18 |
wc
-l
)
"
}
# Pending
...
...
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