Create licenses-generator.sh

This commit is contained in:
huangzhhui 2020-01-19 01:06:29 +08:00
parent 303c6ada7b
commit 01ce930246

43
bin/licenses-generator.sh Normal file
View File

@ -0,0 +1,43 @@
#!/usr/bin/env sh
set -e
# execute `composer global require comcast/php-legal-licenses` before run this shell
NOW=$(date +%s)
BASEPATH=$(cd `dirname $0`; cd ../src/; pwd)
repos=$(ls "$BASEPATH")
echo $NOW
cd `dirname $0`; cd ../src/
git checkout master && git checkout -b licenses-generate-"$NOW"
for REPO in $repos
do
echo "Generating $REPO";
cd "./$REPO"
if [ -f "composer.json" ]; then
composer update -q
php-legal-licenses generate
fi
if [ -f "composer.lock" ]; then
rm -rf ./composer.lock
fi
if [ -d "vendor" ]; then
rm -rf ./vendor
fi
if [ -f "licenses.md" ]; then
git add ./licenses.md
fi
cd ../
done
git commit -m "Update licenses.md"
git push
TIME=$(echo "$(date +%s) - $NOW" | bc)
printf "Execution time: %f seconds" "$TIME"