2024-10-18 12:33:36 +04:00
|
|
|
#!/bin/bash
|
|
|
|
# -*- coding: utf-8 mode: sh -*- vim:sw=4:sts=4:et:ai:si:sta:fenc=utf-8
|
|
|
|
source "$(dirname -- "$0")/../load.sh" || exit 1
|
|
|
|
|
|
|
|
function runphp_help() {
|
|
|
|
echo "$MYNAME: lance un programme dans un environnement PHP prédéfini pour le projet
|
|
|
|
|
|
|
|
USAGE
|
|
|
|
$MYNAME ci|cu|composer
|
|
|
|
$MYNAME command [args...]
|
|
|
|
|
|
|
|
COMPOSER
|
|
|
|
|
|
|
|
pour ces commandes, le répertoire courant est forcé au répertoire du projet
|
|
|
|
composer
|
|
|
|
|
|
|
|
ci
|
|
|
|
installer les dépendances du projet avec composer
|
|
|
|
cu
|
|
|
|
mettre à jour les dépendances du projet avec composer
|
|
|
|
composer [args...]
|
|
|
|
lancer composer avec les arguments spécifiés
|
|
|
|
|
|
|
|
COMMAND"
|
|
|
|
}
|
|
|
|
|
|
|
|
SOPTS=+
|
|
|
|
LOPTS=help
|
|
|
|
args="$(getopt -n runphp -o "$SOPTS" -l "$LOPTS" -- "$@")" || exit 1; eval "set -- $args"
|
|
|
|
|
|
|
|
while [ $# -gt 0 ]; do
|
|
|
|
case "$1" in
|
|
|
|
--) shift; break;;
|
|
|
|
--help) runphp_help; exit 0;;
|
|
|
|
*) die "$1: option non configurée";;
|
|
|
|
esac
|
|
|
|
shift
|
|
|
|
done
|
|
|
|
|
|
|
|
# chercher d'abord le répertoire du projet
|
|
|
|
PROJDIR=
|
|
|
|
while true; do
|
|
|
|
cwd="$(pwd)"
|
|
|
|
if [ -f .runphp.conf ]; then
|
|
|
|
PROJDIR="$cwd"
|
|
|
|
break
|
|
|
|
elif [ -f composer.json ]; then
|
|
|
|
PROJDIR="$cwd"
|
|
|
|
break
|
|
|
|
fi
|
|
|
|
if [ "$cwd" == "$HOME" -o "$cwd" == / ]; then
|
|
|
|
die "Impossible de trouver un projet PHP"
|
|
|
|
fi
|
|
|
|
cd ..
|
|
|
|
done
|
|
|
|
|
|
|
|
export RUNPHP_STANDALONE=
|
|
|
|
RUNPHP=; DIST=; REGISTRY=
|
|
|
|
if [ -f "$PROJDIR/.runphp.conf" ]; then
|
|
|
|
source "$PROJDIR/.runphp.conf"
|
|
|
|
[ -n "$RUNPHP" ] && exec "$PROJDIR/$RUNPHP" "$@"
|
|
|
|
elif [ -f "$PROJDIR/sbin/runphp" ]; then
|
|
|
|
exec "$PROJDIR/sbin/runphp" "$@"
|
2024-10-18 15:28:55 +04:00
|
|
|
elif [ -f "$PROJDIR/runphp" ]; then
|
|
|
|
exec "$PROJDIR/runphp" "$@"
|
2024-10-18 12:33:36 +04:00
|
|
|
fi
|
|
|
|
|
2024-10-18 15:28:55 +04:00
|
|
|
export RUNPHP_STANDALONE="$NULIBDIR"
|
2024-10-18 12:33:36 +04:00
|
|
|
export RUNPHP_PROJDIR="$PROJDIR"
|
|
|
|
export RUNPHP_REGISTRY="$REGISTRY"
|
|
|
|
export RUNPHP_DIST="$DIST"
|
2024-10-18 15:28:55 +04:00
|
|
|
exec "$MYDIR/../runphp/runphp" "$@"
|