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 @@ ...@@ -2,6 +2,8 @@
function readEnv { function readEnv {
if [[ -f ".env" ]]; then if [[ -f ".env" ]]; then
# shellcheck disable=SC2046
# shellcheck disable=SC2002
export $(cat .env | xargs) > /dev/null 2>&1 export $(cat .env | xargs) > /dev/null 2>&1
fi fi
} }
...@@ -19,6 +21,9 @@ function restoreEnvFile { ...@@ -19,6 +21,9 @@ function restoreEnvFile {
echo "COMPOSE_PROJECT_NAME=${COMPOSE_PROJECT_NAME}" >>.env echo "COMPOSE_PROJECT_NAME=${COMPOSE_PROJECT_NAME}" >>.env
fi fi
if [[ -f ".env" ]]; then if [[ -f ".env" ]]; then
# shellcheck disable=SC2046
# shellcheck disable=SC2094
# shellcheck disable=SC2002
env -i $(cat .env | xargs) >.env env -i $(cat .env | xargs) >.env
fi fi
} }
...@@ -29,9 +34,9 @@ function create { ...@@ -29,9 +34,9 @@ function create {
fi fi
truncateCurrentDirectory truncateCurrentDirectory
if [[ -n ${REPOSITORY} ]]; then if [[ -n ${REPOSITORY} ]]; then
composer create-project ${PROJECT} . --no-interaction --repository ${REPOSITORY} composer create-project "${PROJECT}" . --no-interaction --repository "${REPOSITORY}"
else else
composer create-project ${PROJECT} . --no-interaction composer create-project "${PROJECT}" . --no-interaction
fi fi
restoreEnvFile restoreEnvFile
...@@ -51,26 +56,26 @@ function create { ...@@ -51,26 +56,26 @@ function create {
fi fi
# Dump database # Dump database
if [[ -n ${L3D_DUMP_DB} ]]; then if [[ $L3D_DUMP_DB -eq 1 ]]; then
git ignore "/*.sql" git ignore "/*.sql"
drush sql:dump --result-file ../db.sql drush sql:dump --result-file ../db.sql
fi fi
# Cleanup # Cleanup
if [[ -n ${L3D_CLEANUP} ]]; then if [[ $L3D_CLEANUP -eq 1 ]]; then
docker-compose stop docker-compose stop
docker-compose rm --force docker-compose rm --force
fi fi
fi fi
fi fi
if [[ -n ${L3D_EXIT} ]]; then if [[ $L3D_EXIT -eq 1 ]]; then
exit exit
fi fi
} }
function clone { function clone {
truncateCurrentDirectory truncateCurrentDirectory
git clone ${REPOSITORY} . git clone "${REPOSITORY}" .
composer update composer update
restoreEnvFile restoreEnvFile
} }
...@@ -88,6 +93,7 @@ function initialSetup { ...@@ -88,6 +93,7 @@ function initialSetup {
echo "" echo ""
while true; do while true; do
# shellcheck disable=SC2162
read -p "Choose an option: " OPTION read -p "Choose an option: " OPTION
case ${OPTION} in case ${OPTION} in
0 ) 0 )
...@@ -108,13 +114,16 @@ function initialSetup { ...@@ -108,13 +114,16 @@ function initialSetup {
;; ;;
3 ) 3 )
# shellcheck disable=SC2162
read -p "Custom project template: " PROJECT read -p "Custom project template: " PROJECT
# shellcheck disable=SC2162
read -p "Repository URL (optional): " REPOSITORY read -p "Repository URL (optional): " REPOSITORY
create create
break break
;; ;;
4 ) 4 )
# shellcheck disable=SC2162
read -p "Repository URL: " REPOSITORY read -p "Repository URL: " REPOSITORY
if [[ -n "${REPOSITORY}" ]]; then if [[ -n "${REPOSITORY}" ]]; then
clone clone
...@@ -131,7 +140,7 @@ function initialSetup { ...@@ -131,7 +140,7 @@ function initialSetup {
readEnv readEnv
EXISTING=$(ls -1) EXISTING=$(ls -1)
if [[ ! -n "$EXISTING" ]]; then if [[ -z "$EXISTING" ]]; then
if [[ -n ${PROJECT} ]]; then if [[ -n ${PROJECT} ]]; then
create create
elif [[ -n ${REPOSITORY} ]]; then 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