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
e2275685
Commit
e2275685
authored
Jan 17, 2015
by
Hunter Loftis
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
test and implementation for error on failure to parse package.json
parent
d020d2a2
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
49 additions
and
22 deletions
+49
-22
compile
bin/compile
+1
-20
test
bin/test
+2
-1
build.sh
lib/build.sh
+35
-0
common.sh
lib/common.sh
+11
-1
No files found.
bin/compile
View file @
e2275685
...
...
@@ -31,26 +31,7 @@ trap build_failed ERR
####### Determine current state
head
"Reading application state"
info
"package.json..."
iojs_engine
=
$(
read_json
"
$build_dir
/package.json"
".engines.iojs"
)
node_engine
=
$(
read_json
"
$build_dir
/package.json"
".engines.node"
)
npm_engine
=
$(
read_json
"
$build_dir
/package.json"
".engines.npm"
)
info
"build directory..."
start_method
=
$(
get_start_method
"
$build_dir
"
)
modules_source
=
$(
get_modules_source
"
$build_dir
"
)
info
"cache directory..."
npm_previous
=
$(
file_contents
"
$cache_dir
/node/npm-version"
)
node_previous
=
$(
file_contents
"
$cache_dir
/node/node-version"
)
modules_cached
=
$(
get_modules_cached
"
$cache_dir
"
)
info
"environment variables..."
export_env_dir
$env_dir
export
NPM_CONFIG_PRODUCTION
=
${
NPM_CONFIG_PRODUCTION
:-
true
}
export
NODE_MODULES_CACHE
=
${
NODE_MODULES_CACHE
:-
true
}
read_current_state
show_current_state
if
[
"
$iojs_engine
"
==
""
]
;
then
...
...
bin/test
View file @
e2275685
...
...
@@ -24,7 +24,7 @@ testBadJson() {
assertCaptured
"We're sorry this build is failing"
assertNotCaptured
"build directory..."
assertNotCaptured
"Installing binaries"
assertCapturedError 1
""
assertCapturedError 1
"
Unable to parse
"
}
testIoJs
()
{
...
...
@@ -206,6 +206,7 @@ testProcfileAbsentNpmStartPresent() {
testProcfileAbsentNpmStartAbsent
()
{
compile
"procfile-absent-npm-start-absent"
assertCaptured
"Start mechanism: none"
assertCaptured
"None found"
assertNotCaptured
"new Procfile"
assertCapturedSuccess
}
...
...
lib/build.sh
View file @
e2275685
...
...
@@ -53,6 +53,39 @@ get_modules_cached() {
fi
}
# Sets:
# iojs_engine
# node_engine
# npm_engine
# start_method
# modules_source
# npm_previous
# node_previous
# modules_cached
# environment variables (from ENV_DIR)
read_current_state
()
{
info
"package.json..."
assert_json
"
$build_dir
/package.json"
iojs_engine
=
$(
read_json
"
$build_dir
/package.json"
".engines.iojs"
)
node_engine
=
$(
read_json
"
$build_dir
/package.json"
".engines.node"
)
npm_engine
=
$(
read_json
"
$build_dir
/package.json"
".engines.npm"
)
info
"build directory..."
start_method
=
$(
get_start_method
"
$build_dir
"
)
modules_source
=
$(
get_modules_source
"
$build_dir
"
)
info
"cache directory..."
npm_previous
=
$(
file_contents
"
$cache_dir
/node/npm-version"
)
node_previous
=
$(
file_contents
"
$cache_dir
/node/node-version"
)
modules_cached
=
$(
get_modules_cached
"
$cache_dir
"
)
info
"environment variables..."
export_env_dir
$env_dir
export
NPM_CONFIG_PRODUCTION
=
${
NPM_CONFIG_PRODUCTION
:-
true
}
export
NODE_MODULES_CACHE
=
${
NODE_MODULES_CACHE
:-
true
}
}
show_current_state
()
{
echo
""
if
[
"
$iojs_engine
"
==
""
]
;
then
...
...
@@ -172,6 +205,8 @@ ensure_procfile() {
elif
[
"
$start_method
"
==
"server.js"
]
;
then
info
"No Procfile; Adding 'web: node server.js' to new Procfile"
echo
"web: node server.js"
>
$build_dir
/Procfile
else
info
"None found"
fi
}
...
...
lib/common.sh
View file @
e2275685
error
()
{
echo
" !
$*
"
>
&2
exit
1
echo
""
return
1
}
head
()
{
...
...
@@ -27,6 +28,15 @@ achievement() {
echo
""
}
assert_json
()
{
local
file
=
$1
if
test
-f
$file
;
then
if
!
cat
$file
|
$bp_dir
/vendor/jq
'.'
>
/dev/null
;
then
error
"Unable to parse
$file
as JSON"
fi
fi
}
file_contents
()
{
if
test
-f
$1
;
then
echo
"
$(
cat
$1
)
"
...
...
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