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
5085334c
Commit
5085334c
authored
Feb 23, 2016
by
Tom Spencer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added heroku prebuild and postbuild scripts
parent
a8cf29ac
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
51 additions
and
2 deletions
+51
-2
compile
bin/compile
+5
-2
dependencies.sh
lib/dependencies.sh
+20
-0
README.md
test/fixtures/pre-post-build-scripts/README.md
+1
-0
package.json
test/fixtures/pre-post-build-scripts/package.json
+16
-0
run
test/run
+9
-0
No files found.
bin/compile
View file @
5085334c
...
@@ -118,11 +118,14 @@ header "Restoring cache"
...
@@ -118,11 +118,14 @@ header "Restoring cache"
restore_cache | output
"
$LOG_FILE
"
restore_cache | output
"
$LOG_FILE
"
build_dependencies
()
{
build_dependencies
()
{
local
has_prebuild_script
=
$(
read_json
"
$BUILD_DIR
/package.json"
".scripts[
\"
heroku-prebuild
\"
]"
)
local
has_postbuild_script
=
$(
read_json
"
$BUILD_DIR
/package.json"
".scripts[
\"
heroku-postbuild
\"
]"
)
if
$PREBUILD
;
then
if
$PREBUILD
;
then
echo
"Prebuild detected (node_modules already exists)"
echo
"Prebuild detected (node_modules already exists)"
rebuild_node_modules
"
$BUILD_DIR
"
rebuild_node_modules
"
$BUILD_DIR
"
"
$has_prebuild_script
"
"
$has_postbuild_script
"
else
else
install_node_modules
"
$BUILD_DIR
"
install_node_modules
"
$BUILD_DIR
"
"
$has_prebuild_script
"
"
$has_postbuild_script
"
fi
fi
}
}
...
...
lib/dependencies.sh
View file @
5085334c
install_node_modules
()
{
install_node_modules
()
{
local
build_dir
=
${
1
:-}
local
build_dir
=
${
1
:-}
local
has_prebuild_script
=
${
2
:-}
local
has_postbuild_script
=
${
3
:-}
if
[
-e
$build_dir
/package.json
]
;
then
if
[
-e
$build_dir
/package.json
]
;
then
cd
$build_dir
cd
$build_dir
if
[
-n
"
$has_prebuild_script
"
]
;
then
echo
"Running prebuild script"
npm run heroku-prebuild
fi
echo
"Pruning any extraneous modules"
echo
"Pruning any extraneous modules"
npm prune
--unsafe-perm
--userconfig
$build_dir
/.npmrc 2>&1
npm prune
--unsafe-perm
--userconfig
$build_dir
/.npmrc 2>&1
if
[
-e
$build_dir
/npm-shrinkwrap.json
]
;
then
if
[
-e
$build_dir
/npm-shrinkwrap.json
]
;
then
...
@@ -11,6 +17,10 @@ install_node_modules() {
...
@@ -11,6 +17,10 @@ install_node_modules() {
echo
"Installing node modules (package.json)"
echo
"Installing node modules (package.json)"
fi
fi
npm
install
--unsafe-perm
--userconfig
$build_dir
/.npmrc 2>&1
npm
install
--unsafe-perm
--userconfig
$build_dir
/.npmrc 2>&1
if
[
-n
"
$has_postbuild_script
"
]
;
then
echo
"Running postbuild script"
npm run heroku-postbuild
fi
else
else
echo
"Skipping (no package.json)"
echo
"Skipping (no package.json)"
fi
fi
...
@@ -18,9 +28,15 @@ install_node_modules() {
...
@@ -18,9 +28,15 @@ install_node_modules() {
rebuild_node_modules
()
{
rebuild_node_modules
()
{
local
build_dir
=
${
1
:-}
local
build_dir
=
${
1
:-}
local
has_prebuild_script
=
${
2
:-}
local
has_postbuild_script
=
${
3
:-}
if
[
-e
$build_dir
/package.json
]
;
then
if
[
-e
$build_dir
/package.json
]
;
then
cd
$build_dir
cd
$build_dir
if
[
-n
"
$has_prebuild_script
"
]
;
then
echo
"Running prebuild script"
npm run heroku-prebuild
fi
echo
"Rebuilding any native modules"
echo
"Rebuilding any native modules"
npm rebuild 2>&1
npm rebuild 2>&1
if
[
-e
$build_dir
/npm-shrinkwrap.json
]
;
then
if
[
-e
$build_dir
/npm-shrinkwrap.json
]
;
then
...
@@ -29,6 +45,10 @@ rebuild_node_modules() {
...
@@ -29,6 +45,10 @@ rebuild_node_modules() {
echo
"Installing any new modules (package.json)"
echo
"Installing any new modules (package.json)"
fi
fi
npm
install
--unsafe-perm
--userconfig
$build_dir
/.npmrc 2>&1
npm
install
--unsafe-perm
--userconfig
$build_dir
/.npmrc 2>&1
if
[
-n
"
$has_postbuild_script
"
]
;
then
echo
"Running postbuild script"
npm run heroku-postbuild
fi
else
else
echo
"Skipping (no package.json)"
echo
"Skipping (no package.json)"
fi
fi
...
...
test/fixtures/pre-post-build-scripts/README.md
0 → 100644
View file @
5085334c
A fake README, to keep npm from polluting stderr.
\ No newline at end of file
test/fixtures/pre-post-build-scripts/package.json
0 → 100644
View file @
5085334c
{
"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"
:
{
"heroku-prebuild"
:
"echo heroku-prebuild hook message"
,
"heroku-postbuild"
:
"echo heroku-postbuild hook message"
}
}
test/run
View file @
5085334c
...
@@ -471,6 +471,15 @@ testMultiExport() {
...
@@ -471,6 +471,15 @@ testMultiExport() {
assertCapturedSuccess
assertCapturedSuccess
}
}
testPrePostBuildScripts
()
{
compile
"pre-post-build-scripts"
assertCaptured
"Running prebuild script"
assertCaptured
"echo heroku-prebuild hook message"
assertCaptured
"Running postbuild script"
assertCaptured
"echo heroku-postbuild hook message"
assertCapturedSuccess
}
# Utils
# Utils
pushd
$(
dirname
0
)
>
/dev/null
pushd
$(
dirname
0
)
>
/dev/null
...
...
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