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
c1f13bf0
Commit
c1f13bf0
authored
Sep 12, 2013
by
zeke
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
stringify semver pattern for requested version
parent
b8953749
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
22 additions
and
24 deletions
+22
-24
common.sh
bin/common.sh
+6
-3
compile
bin/compile
+12
-10
test
bin/test
+1
-8
package.json
test/package-json-invalidversion/package.json
+1
-1
package.json
test/package-json-stable-version/package.json
+1
-1
package.json
test/package-json-unstable-version/package.json
+1
-1
No files found.
bin/common.sh
View file @
c1f13bf0
...
...
@@ -3,7 +3,8 @@
# fail fast
set
-e
# debug
# Uncomment the line below to enable debugging when
# working on the buildpack
# set -x
download_and_install_node
()
{
...
...
@@ -11,7 +12,10 @@ download_and_install_node() {
node_url
=
"http://s3pository.heroku.com/node/v
$version
/node-v
$version
-linux-x64.tar.gz"
curl
$node_url
-s
-o
- |
tar
xzf -
-C
$build_dir
mkdir
-p
$build_dir
/vendor
# Remove node in case we're overwriting a previously-downloaded version
rm
-rf
$build_dir
/vendor/node
mv
$build_dir
/node-v
$version
-linux-x64
$build_dir
/vendor/node
chmod
+x
$build_dir
/vendor/node/bin/
*
PATH
=
$PATH
:
$build_dir
/vendor/node/bin
...
...
@@ -46,7 +50,6 @@ status() {
echo
"----->
$*
"
}
# sed -l basically makes sed replace and buffer through stdin to stdout
# so you get updates while the command runs and dont wait for the end
# e.g. npm install | indent
...
...
@@ -59,5 +62,5 @@ indent() {
}
function
cat_npm_debug_log
()
{
[
-f
$build_dir
/npm-debug.log
]
&&
cat
$build_dir
/npm-debug.log
test
-f
$build_dir
/npm-debug.log
&&
cat
$build_dir
/npm-debug.log
}
bin/compile
View file @
c1f13bf0
...
...
@@ -30,23 +30,25 @@ if ! test $requested_version; then
else
# Does the already-downloaded stable version of node satisfy the requested version?
default_satisfies
=
$(
node
$bp_dir
/vendor/semver/bin/semver
-v
"
$
{
stable_version
}
"
-r
"
${
requested_version
}
"
||
echo
""
)
default_satisfies
=
$(
node
$bp_dir
/vendor/semver/bin/semver
-v
"
$
stable_version
"
-r
"
$requested_version
"
||
echo
""
)
if
test
$default_satisfies
;
then
status
"Latest stable node v
$stable_version
satisfies engines.node:
$requested
"
node_version
=
$stable_version
else
# Find all available versions from nodejs.org/dist
# Fetch all versions of node from nodejs.org/dist and format them into
# a string that the semver binary will appreciate.
# e.g. semver -v "0.10.0" -v "0.10.1" -v "0.10.2" -r ">0.8"
# See https://github.com/isaacs/node-semver/blob/master/bin/semver
args
=
""
for
version
in
$(
query_all_versions
)
;
do
args
=
"
${
args
}
-v
\"
${
version
}
\"
"
;
done
args
=
"
${
args
}
-r
\"
${
requested_version
}
\"
"
# Determine which available versions satisfy the requested version
# https://github.com/isaacs/node-semver/blob/master/bin/semver
evaluated_versions
=
$(
eval
node
$bp_dir
/vendor/semver/bin/semver
${
args
}
||
echo
""
)
# Find all versions that satisfy.
satisfying_versions
=
$(
eval
$bp_dir
/vendor/semver/bin/semver
${
args
})
# Use the latest o
f the evaluated versions
node_version
=
$(
echo
$evaluated_versions
|
tail
-n
1
)
# Use the latest o
ne.
node_version
=
$(
echo
"
$satisfying_versions
"
|
tail
-n
1
)
if
test
$node_version
;
then
status
"Downloading and installing node v
$version
"
...
...
@@ -62,9 +64,9 @@ cache_store_dir="$cache_dir/node_modules/$node_version"
cache_target_dir
=
"
$build_dir
/node_modules"
# Restore node_modules from cache, if present
if
[
-d
$cache_store_dir
]
;
then
if
test
-d
$cache_store_dir
;
then
status
"Restoring node_modules cache"
if
[
-d
$cache_target_dir
]
;
then
if
test
-d
$cache_target_dir
;
then
cp
-r
$cache_store_dir
/
*
$cache_target_dir
/
else
cp
-r
$cache_store_dir
$cache_target_dir
...
...
@@ -80,7 +82,7 @@ npm install --production | indent
npm rebuild | indent
# Cache node_modules for future builds
if
[
-d
$cache_target_dir
]
;
then
if
test
-d
$cache_target_dir
;
then
status
"Caching node_modules for future builds"
rm
-rf
$cache_store_dir
mkdir
-p
$(
dirname
$cache_store_dir
)
...
...
bin/test
View file @
c1f13bf0
#!/usr/bin/env bash
#
# Create a Heroku app with the following buildpack:
# https://github.com/ddollar/buildpack-test
#
# Push this Node.js buildpack to that Heroku app to
# run the tests
#
# See CONTRIBUTING.md for info on running these tests.
testDetectWithPackageJson
()
{
detect
"package-json-stable-version"
...
...
test/package-json-invalidversion/package.json
View file @
c1f13bf0
...
...
@@ -7,6 +7,6 @@
"url"
:
"http://github.com/example/example.git"
},
"engines"
:
{
"node"
:
"
5
.0"
"node"
:
"
>2
.0"
}
}
test/package-json-stable-version/package.json
View file @
c1f13bf0
...
...
@@ -7,6 +7,6 @@
"url"
:
"http://github.com/example/example.git"
},
"engines"
:
{
"node"
:
"
0.10.x
"
"node"
:
"
>0.10.0
"
}
}
test/package-json-unstable-version/package.json
View file @
c1f13bf0
...
...
@@ -7,6 +7,6 @@
"url"
:
"http://github.com/example/example.git"
},
"engines"
:
{
"node"
:
"
0.11.5
"
"node"
:
"
>0.11.0
"
}
}
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