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
--- 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