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
5a615b1b
Commit
5a615b1b
authored
Oct 16, 2013
by
zeke
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
When restoring from cache, run `npm install` to ensure pre- and post-install scripts are run.
parent
b82b5bf0
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
74 additions
and
27 deletions
+74
-27
compile
bin/compile
+12
-6
test
bin/test
+33
-21
README.md
test/no-script-hooks/README.md
+1
-0
package.json
test/no-script-hooks/package.json
+12
-0
README.md
test/script-hooks/README.md
+1
-0
package.json
test/script-hooks/package.json
+15
-0
No files found.
bin/compile
View file @
5a615b1b
...
@@ -63,21 +63,27 @@ if test -d $cache_dir; then
...
@@ -63,21 +63,27 @@ if test -d $cache_dir; then
status
"package.json unchanged since last build"
status
"package.json unchanged since last build"
status
"Restoring node_modules from cache"
status
"Restoring node_modules from cache"
test
-d
$cache_dir
/node_modules
&&
cp
-r
$cache_dir
/node_modules
$build_dir
/
test
-d
$cache_dir
/node_modules
&&
cp
-r
$cache_dir
/node_modules
$build_dir
/
# cp -r $cache_dir/vendor/node $build_dir/vendor/
else
status
"Installing dependencies"
# If any scripts are defined in package.json, trigger them.
npm
install
--production
| indent
# https://npmjs.org/doc/misc/npm-scripts.html
hook_scripts
=
$(
cat
$build_dir
/package.json |
$bp_dir
/vendor/jq
-r
.scripts
)
if
[
"
$hook_scripts
"
!=
"null"
]
;
then
status
"Running npm install to trigger script hooks"
npm
install
--production
| indent
fi
else
status
"Rebuilding dependencies"
status
"Rebuilding dependencies"
npm rebuild | indent
npm rebuild | indent
status
"Installing dependencies"
npm
install
--production
| indent
status
"Caching node_modules for future builds"
status
"Caching node_modules for future builds"
rm
-rf
$cache_dir
rm
-rf
$cache_dir
mkdir
-p
$cache_dir
mkdir
-p
$cache_dir
# mkdir -p $cache_dir/vendor
test
-d
$build_dir
/node_modules
&&
cp
-r
$build_dir
/node_modules
$cache_dir
/
test
-d
$build_dir
/node_modules
&&
cp
-r
$build_dir
/node_modules
$cache_dir
/
# cp -r $build_dir/vendor/node $cache_dir/vendor/
fi
fi
# Update the PATH
# Update the PATH
...
...
bin/test
View file @
5a615b1b
...
@@ -49,16 +49,6 @@ testUnstableVersion() {
...
@@ -49,16 +49,6 @@ testUnstableVersion() {
assertCapturedSuccess
assertCapturedSuccess
}
}
# testInvalidVersion() {
# compile "invalid-node-version"
# assertCapturedError 1 "not found among available versions"
# }
# testInvalidVersion() {
# compile "invalid-dependency"
# assertCapturedError 1 "not in the npm registry"
# }
testProfileCreated
()
{
testProfileCreated
()
{
compile
"stable-node"
compile
"stable-node"
assertCaptured
"Building runtime environment"
assertCaptured
"Building runtime environment"
...
@@ -78,7 +68,7 @@ testNodeModulesCached() {
...
@@ -78,7 +68,7 @@ testNodeModulesCached() {
assertEquals
"1"
"
$(
ls
-1
$cache
/ |
wc
-l
)
"
assertEquals
"1"
"
$(
ls
-1
$cache
/ |
wc
-l
)
"
}
}
# Pending
# Pending
Tests
# testNodeBinariesAddedToPath() {
# testNodeBinariesAddedToPath() {
# }
# }
...
@@ -86,13 +76,35 @@ testNodeModulesCached() {
...
@@ -86,13 +76,35 @@ testNodeModulesCached() {
# testNodeModulesRestoredFromCache() {
# testNodeModulesRestoredFromCache() {
# }
# }
## utils ########################################
# TODO: Figure out how to test stuff like script hooks
# when restoring node_modules from cache
# testScriptHooks() {
# compile "script-hooks"
# assertCaptured "trigger script hooks"
# assertCaptured "preinstall hook message"
# assertCapturedSuccess
# }
# testWithoutScriptHooks() {
# compile "no-script-hooks"
# assertNotCaptured "trigger script hooks"
# assertCapturedSuccess
# }
# testInvalidVersion() {
# compile "invalid-node-version"
# assertCapturedError 1 "not found among available versions"
# }
# Utils
pushd
$(
dirname
0
)
>
/dev/null
pushd
$(
dirname
0
)
>
/dev/null
BASE
=
$(
pwd
)
bp_dir
=
$(
pwd
)
popd
>
/dev/null
popd
>
/dev/null
source
${
BASE
}
/vendor/test-utils/test-utils
source
${
bp_dir
}
/vendor/test-utils/test-utils
mktmpdir
()
{
mktmpdir
()
{
dir
=
$(
mktemp
-t
testXXXXX
)
dir
=
$(
mktemp
-t
testXXXXX
)
...
@@ -102,19 +114,19 @@ mktmpdir() {
...
@@ -102,19 +114,19 @@ mktmpdir() {
}
}
detect
()
{
detect
()
{
capture
${
BASE
}
/bin/detect
${
BASE
}
/test/
$1
capture
${
bp_dir
}
/bin/detect
${
bp_dir
}
/test/
$1
}
}
COMPILE_DIR
=
""
compile_dir
=
""
compile
()
{
compile
()
{
COMPILE_DIR
=
$(
mktmpdir
)
compile_dir
=
$(
mktmpdir
)
cp
-r
${
BASE
}
/test/
$1
/
*
${
COMPILE_DIR
}
/
cp
-r
${
bp_dir
}
/test/
$1
/
*
${
compile_dir
}
/
capture
${
BASE
}
/bin/compile
${
COMPILE_DIR
}
${
2
:-$(
mktmpdir
)}
capture
${
bp_dir
}
/bin/compile
${
compile_dir
}
${
2
:-$(
mktmpdir
)}
}
}
assertFile
()
{
assertFile
()
{
assertEquals
"
$1
"
"
$(
cat
${
COMPILE_DIR
}
/
$2
)
"
assertEquals
"
$1
"
"
$(
cat
${
compile_dir
}
/
$2
)
"
}
}
source
${
BASE
}
/vendor/shunit2/shunit2
source
${
bp_dir
}
/vendor/shunit2/shunit2
test/no-script-hooks/README.md
0 → 100644
View file @
5a615b1b
A fake README, to keep npm from polluting stderr.
\ No newline at end of file
test/no-script-hooks/package.json
0 → 100644
View file @
5a615b1b
{
"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"
},
"engines"
:
{
"node"
:
"~0.10.0"
}
}
test/script-hooks/README.md
0 → 100644
View file @
5a615b1b
A fake README, to keep npm from polluting stderr.
\ No newline at end of file
test/script-hooks/package.json
0 → 100644
View file @
5a615b1b
{
"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"
},
"engines"
:
{
"node"
:
"~0.10.0"
},
"scripts"
:
{
"preinstall"
:
"echo preinstall hook message"
}
}
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