Skip to content
Snippets Groups Projects
Commit e552a6f1 authored by jurgenhaas's avatar jurgenhaas
Browse files

customer/bison/core#14 Make variable checks more explicit and cleanup code

parent 08671cf6
No related branches found
No related tags found
No related merge requests found
......@@ -2,6 +2,8 @@
function readEnv {
if [[ -f ".env" ]]; then
# shellcheck disable=SC2046
# shellcheck disable=SC2002
export $(cat .env | xargs) > /dev/null 2>&1
fi
}
......@@ -19,6 +21,9 @@ function restoreEnvFile {
echo "COMPOSE_PROJECT_NAME=${COMPOSE_PROJECT_NAME}" >>.env
fi
if [[ -f ".env" ]]; then
# shellcheck disable=SC2046
# shellcheck disable=SC2094
# shellcheck disable=SC2002
env -i $(cat .env | xargs) >.env
fi
}
......@@ -29,9 +34,9 @@ function create {
fi
truncateCurrentDirectory
if [[ -n ${REPOSITORY} ]]; then
composer create-project ${PROJECT} . --no-interaction --repository ${REPOSITORY}
composer create-project "${PROJECT}" . --no-interaction --repository "${REPOSITORY}"
else
composer create-project ${PROJECT} . --no-interaction
composer create-project "${PROJECT}" . --no-interaction
fi
restoreEnvFile
......@@ -51,26 +56,26 @@ function create {
fi
# Dump database
if [[ -n ${L3D_DUMP_DB} ]]; then
if [[ $L3D_DUMP_DB -eq 1 ]]; then
git ignore "/*.sql"
drush sql:dump --result-file ../db.sql
fi
# Cleanup
if [[ -n ${L3D_CLEANUP} ]]; then
if [[ $L3D_CLEANUP -eq 1 ]]; then
docker-compose stop
docker-compose rm --force
fi
fi
fi
if [[ -n ${L3D_EXIT} ]]; then
if [[ $L3D_EXIT -eq 1 ]]; then
exit
fi
}
function clone {
truncateCurrentDirectory
git clone ${REPOSITORY} .
git clone "${REPOSITORY}" .
composer update
restoreEnvFile
}
......@@ -88,6 +93,7 @@ function initialSetup {
echo ""
while true; do
# shellcheck disable=SC2162
read -p "Choose an option: " OPTION
case ${OPTION} in
0 )
......@@ -108,13 +114,16 @@ function initialSetup {
;;
3 )
# shellcheck disable=SC2162
read -p "Custom project template: " PROJECT
# shellcheck disable=SC2162
read -p "Repository URL (optional): " REPOSITORY
create
break
;;
4 )
# shellcheck disable=SC2162
read -p "Repository URL: " REPOSITORY
if [[ -n "${REPOSITORY}" ]]; then
clone
......@@ -131,7 +140,7 @@ function initialSetup {
readEnv
EXISTING=$(ls -1)
if [[ ! -n "$EXISTING" ]]; then
if [[ -z "$EXISTING" ]]; then
if [[ -n ${PROJECT} ]]; then
create
elif [[ -n ${REPOSITORY} ]]; then
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment