testing; Check node version during create-test-environment (bug 1282912); r?mars draft
authorbyron jones <glob@mozilla.com>
Wed, 29 Jun 2016 12:57:23 +0800
changeset 8683 264f6fbd8ed40bf216996f085b0ff6e07a58bd37
parent 8682 7cb2bc2d439be759a5945751c1f680204829d2d4
push id962
push userbjones@mozilla.com
push dateWed, 29 Jun 2016 05:00:31 +0000
reviewersmars
bugs1282912
testing; Check node version during create-test-environment (bug 1282912); r?mars create-test-environment hangs waiting for user input on really old node versions due to the lack of support for the -y switch, requiring us to check the version of node. MozReview-Commit-ID: LNhSLvuQgOa
create-test-environment
--- a/create-test-environment
+++ b/create-test-environment
@@ -9,16 +9,37 @@ if [ "x${vercheck}" != "xTrue" ]; then
 fi
 
 # We need node.js for tools required to package/install Review Board
 # (eg. lessc, uglifyjs)
 if ! type npm >/dev/null 2>&1; then
   echo "npm not found.  Please install node.js."
   exit 1
 fi
+
+# Some Linux distros use 'nodejs' instead of 'node' as the executable
+if type node >/dev/null 2>&1; then
+    node_bin=node
+elif type nodejs >/dev/null 2>&1; then
+    node_bin=nodejs
+else
+    echo "Failed to determine node executable name."
+    exit 1
+fi
+
+# Check the node.js version - lessc needs 0.12
+function version {
+    echo "$@" | sed "s/^v//" | awk -F. '{ printf("%d%03d%03d%03d\n", $1,$2,$3,$4); }'
+}
+if [ $(version `${node_bin} -v`) -lt $(version "0.12") ]; then
+    echo "node.js is too old."
+    echo "Found $(${node_bin} -v), test environment requires v0.12+"
+    exit 1
+fi
+
 # More annoyingly we need msgfmt which is part of gettext.
 if ! type msgfmt >/dev/null 2>&1; then
   echo "msgfmt not found.  Please install the gettext package."
   echo "On OSX you can use homebrew to install this:"
   echo "  brew install gettext && brew link gettext --force"
   exit 1
 fi