Allow PHAN location to be read from PATH
authoraddshore <addshorewiki@gmail.com>
Fri, 23 Dec 2016 14:42:19 +0000 (14:42 +0000)
committeraddshore <addshorewiki@gmail.com>
Fri, 23 Dec 2016 14:54:17 +0000 (14:54 +0000)
Change-Id: I4ea64eab12f299a13559178c80fe6797d07a5f85

tests/phan/bin/phan

index 5d42cf5..6ce1e84 100755 (executable)
@@ -10,9 +10,16 @@ fi
 # Note that this isn't loaded in via composer because then composer can
 # only be run with php7.0
 if [ ! -f "$PHAN" ]; then
-       echo "The environment variable PHAN must point to the 'phan' file"
-       echo "in a checkout of https://github.com/etsy/phan.git"
-       exit 1
+       # If no PHAN is specified then try to get location from PATH
+       export PHAN="$(which phan)"
+       if [ ! -f "$PHAN" ]; then
+               echo "The environment variable PHAN must point to the 'phan' file"
+               echo "in a checkout of https://github.com/etsy/phan.git"
+               echo "Or phan must be included in your PATH"
+               exit 1
+       fi
+else
+       export PHAN="php7.0 $PHAN"
 fi
 
 if [ -z "$MW_INSTALL_PATH" ]; then
@@ -57,7 +64,7 @@ export RUN="${ISSUES}/issues-${REV}"
 
 # Run the analysis, emitting output to the
 # issues file.
-php7.0 $PHAN \
+$PHAN \
        --project-root-directory "$ROOT" \
        --config-file "$CONFIG_FILE" \
        --output "php://stdout" \