From 0300aab643a5187ab7708c4bf1eaf7c261045e7c Mon Sep 17 00:00:00 2001 From: Kris Moore Date: Mon, 8 Feb 2016 12:30:27 -0500 Subject: [PATCH] Update API test script to use 'sudo' if running as user and needing to pkg install utils --- tests/api-test.sh | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/tests/api-test.sh b/tests/api-test.sh index cedbb41..c290493 100755 --- a/tests/api-test.sh +++ b/tests/api-test.sh @@ -17,9 +17,15 @@ DEFCLASS="lifepreserver" # Set variable to call jsawk utility JSAWK="./utils/jsawk -j js24" +if [ `id -u` != "0" ] ; then + pkgPre="sudo" +else + pkgPre="" +fi + which npm >/dev/null 2>/dev/null if [ $? -ne 0 ] ; then - pkg install -y npm + $pkgPre pkg install -y npm if [ $? -ne 0 ] ; then echo "Requires npm!" exit 1 @@ -28,7 +34,7 @@ fi pkg info p5-JSON >/dev/null 2>/dev/null if [ $? -ne 0 ] ; then - pkg install -y p5-JSON + $pkgPre pkg install -y p5-JSON if [ $? -ne 0 ] ; then echo "Requires p5-JSON!" exit 1