Commit 58a473e0 authored by zeke's avatar zeke

line up the strings and get the tests passing again

parent 45f6360d
...@@ -52,8 +52,8 @@ status() { ...@@ -52,8 +52,8 @@ status() {
indent() { indent() {
c='s/^/ /' c='s/^/ /'
case $(uname) in case $(uname) in
Darwin) sed -l "$c";; Darwin) sed -l "$c";; # mac/bsd sed: -l buffers on line boundaries
*) sed -u "$c";; *) sed -u "$c";; # unix/gnu sed: -u unbuffered (arbitrary) chunks of data
esac esac
} }
......
...@@ -8,7 +8,7 @@ stable_version="0.10.18" ...@@ -8,7 +8,7 @@ stable_version="0.10.18"
source $bp_dir/bin/common.sh source $bp_dir/bin/common.sh
# Output debug info on exit # Output debug info on exit
trap cat_npm_debug_log EXIT # trap cat_npm_debug_log EXIT
# Bootstrap the build process with latest stable version of node # Bootstrap the build process with latest stable version of node
# We'll use it to parse package.json and do semver detection # We'll use it to parse package.json and do semver detection
...@@ -16,6 +16,7 @@ download_and_install_node $stable_version ...@@ -16,6 +16,7 @@ download_and_install_node $stable_version
# Is a node version specified in package.json? # Is a node version specified in package.json?
determine_requested_version() { determine_requested_version() {
# https://github.com/trentm/json
v=$(cat $build_dir/package.json | node $bp_dir/vendor/json engines.node 2>/dev/null) v=$(cat $build_dir/package.json | node $bp_dir/vendor/json engines.node 2>/dev/null)
if [ $? == 0 ]; then echo $v; fi if [ $? == 0 ]; then echo $v; fi
} }
...@@ -28,14 +29,14 @@ if ! test $requested_version; then ...@@ -28,14 +29,14 @@ if ! test $requested_version; then
echo "WARNING: No node version specified in package.json, see:" | indent echo "WARNING: No node version specified in package.json, see:" | indent
echo "https://devcenter.heroku.com/articles/nodejs-support#versions" | indent echo "https://devcenter.heroku.com/articles/nodejs-support#versions" | indent
echo echo
status "Defaulting to node v$stable_version (latest stable)" status "Defaulting to latest stable node, v$stable_version"
else else
# Does the already-downloaded stable version of node satisfy the requested version? # 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 if test $default_satisfies; then
status "Using node v$stable_version" status "Latest stable node v$stable_version satisfies engines.node: $requested"
node_version=$stable_version node_version=$stable_version
else else
# Find all available versions from nodejs.org/dist # Find all available versions from nodejs.org/dist
...@@ -53,7 +54,7 @@ else ...@@ -53,7 +54,7 @@ else
if test $node_version; then if test $node_version; then
download_and_install_node $node_version download_and_install_node $node_version
else else
error "Requested node version ${requested_version} not found among available versions on nodejs.org/dist" error "node ${requested_version} not found among available versions on nodejs.org/dist"
fi fi
fi fi
fi fi
......
...@@ -8,41 +8,41 @@ ...@@ -8,41 +8,41 @@
# run the tests # run the tests
# #
# testDetectWithPackageJson() { testDetectWithPackageJson() {
# detect "package-json-stable-version" detect "package-json-stable-version"
# assertCaptured "Node.js" assertCaptured "Node.js"
# assertCapturedSuccess assertCapturedSuccess
# } }
# testDetectWithoutPackageJson() { testDetectWithoutPackageJson() {
# detect "no-package-json" detect "no-package-json"
# assertCapturedError 1 "" assertCapturedError 1 ""
# } }
testPackageJsonWithoutVersion() { testPackageJsonWithoutVersion() {
compile "package-json-noversion" compile "package-json-noversion"
assertCaptured "WARNING: No node version specified" assertCaptured "WARNING: No node version specified"
assertCaptured "Using latest stable node" assertCaptured "Defaulting to latest stable node"
assertCapturedSuccess assertCapturedSuccess
} }
testPackageJsonWithStableVersion() { testPackageJsonWithStableVersion() {
compile "package-json-stable-version" compile "package-json-stable-version"
assertNotCaptured "WARNING: No node version specified" assertNotCaptured "WARNING: No node version specified"
assertCaptured "Using latest stable node" assertCaptured "satisfies engines.node"
assertCapturedSuccess assertCapturedSuccess
} }
testPackageJsonWithUnstableVersion() { testPackageJsonWithUnstableVersion() {
compile "package-json-unstable-version" compile "package-json-unstable-version"
assertCaptured "Using node version 0.11" assertCaptured "Downloading and installing node v0.11"
assertCapturedSuccess assertCapturedSuccess
} }
# testPackageJsonWithInvalidVersion() { testPackageJsonWithInvalidVersion() {
# compile "package-json-invalidversion" compile "package-json-invalidversion"
# assertCapturedError 1 "Requested node version 5.0 not found" assertCapturedError 1 "not found among available versions"
# } }
testProfileCreated() { testProfileCreated() {
compile "package-json-stable-version" compile "package-json-stable-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