Commit 0048d0ca authored by Hunter Loftis's avatar Hunter Loftis

preliminary test and implementation for iojs support

parent bb9f8611
......@@ -33,6 +33,7 @@ export NODE_MODULES_CACHE=${NODE_MODULES_CACHE:-true}
####### Determine current state
iojs_engine=$(read_json "$build_dir/package.json" ".engines.iojs")
node_engine=$(read_json "$build_dir/package.json" ".engines.node")
node_previous=$(file_contents "$cache_dir/node/node-version")
npm_engine=$(read_json "$build_dir/package.json" ".engines.npm")
......@@ -49,7 +50,12 @@ warn_node_modules "$modules_source"
####### Vendor in binaries
head "Installing binaries"
install_node
if [ "$iojs_engine" == "" ]; then
install_node
else
install_iojs
fi
node_engine=`node --version`
install_npm
####### Build the project's dependencies
......
......@@ -18,6 +18,14 @@ testDetectWithoutPackageJson() {
assertCapturedError 1 ""
}
testIoJs() {
compile "iojs"
assertCaptured "Node engine: 1.0."
assertCaptured "(iojs)"
assertCaptured "detected node version: v1.0."
assertCapturedSuccess
}
testNoVersion() {
compile "no-version"
assertCaptured "Node engine: unspecified"
......
......@@ -55,12 +55,16 @@ get_modules_cached() {
show_current_state() {
echo ""
if [ "$iojs_engine" == "" ]; then
info "Node engine: ${node_engine:-unspecified}"
else
achievement "iojs"
info "Node engine: $iojs_engine (iojs)"
fi
info "Npm engine: ${npm_engine:-unspecified}"
info "Start mechanism: ${start_method:-none}"
info "node_modules source: ${modules_source:-none}"
info "node_modules cached: $modules_cached"
echo ""
printenv | grep ^NPM_CONFIG_ | indent
......@@ -85,6 +89,24 @@ install_node() {
PATH=$heroku_dir/node/bin:$PATH
}
install_iojs() {
# Resolve non-specific iojs versions using semver.herokuapp.com
if ! [[ "$node_engine" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
info "Resolving iojs version ${iojs_engine:-(latest stable)} via semver.io..."
iojs_engine=$(curl --silent --get --data-urlencode "range=${iojs_engine}" https://semver.herokuapp.com/iojs/resolve)
fi
# TODO: remove nightly, point at /dist once that's available
info "Downloading and installing iojs $iojs_engine..."
download_url="https://iojs.org/download/nightly/v$iojs_engine-nightly201501135ea716d895/iojs-v$iojs_engine-nightly201501135ea716d895-linux-x64.tar.gz"
curl $download_url -s -o - | tar xzf - -C /tmp
# Move iojs/node (and npm) binaries into .heroku/node and make them executable
mv /tmp/iojs-v$iojs_engine-nightly201501135ea716d895-linux-x64/* $heroku_dir/node
chmod +x $heroku_dir/node/bin/*
PATH=$heroku_dir/node/bin:$PATH
}
install_npm() {
# Optionally bootstrap a different npm version
if [ "$npm_engine" != "" ]; then
......
......@@ -21,6 +21,12 @@ warning() {
echo "" >> $warnings
}
achievement() {
local msg=$1
echo " ACHIEVEMENT UNLOCKED: $msg :)"
echo ""
}
file_contents() {
if test -f $1; then
echo "$(cat $1)"
......
{
"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"
},
"dependencies": {
"hashish": "*"
},
"engines": {
"iojs": "1.0.x"
},
"scripts": {
"postinstall": "echo \"detected node version:\" `node --version`"
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment