-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgoose
executable file
·59 lines (46 loc) · 1.56 KB
/
goose
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
#!/usr/bin/env bash
if [ -z "${BASH}" ]; then
echo "This script can only run in bash. Exiting..." >&2
exit 255
fi
declare -g APP_PATH="$( cd -- "$(dirname "$0")" >/dev/null 2>&1 ; pwd -P )"
declare -g APP_NAME="${0##${APP_PATH}/}"
declare -g PROJECT_PATH="$(pwd)"
[[ "${APP_PATH}" == "${PROJECT_PATH}" && "$1" == "-g" ]] && shift
if [[ "${APP_PATH}" != "${PROJECT_PATH}" && ! -f "${PROJECT_PATH}/${APP_NAME}" ]]; then
PROJECT_PATH="${APP_PATH}"
fi
if [[ "${APP_PATH}" != "${PROJECT_PATH}" && "$1" == "-g" ]]; then
echo "Using external ${APP_NAME}..."
shift
PROJECT_PATH="${APP_PATH}"
elif [[ "${APP_PATH}" != "${PROJECT_PATH}" && -f "${PROJECT_PATH}/${APP_NAME}" ]]; then
echo "Using local ${APP_NAME}..."
${PROJECT_PATH}/${APP_NAME} $@
exit $?
fi
if [[ ! -d "${APP_PATH}/.goose" || ! -f "${APP_PATH}/.goose/core.bash" ]]; then
echo "${PROJECT_PATH}/.goose/core.bash is missing! Critical dependency! Exiting..." >&2
exit 255
fi
source ${APP_PATH}/.goose/core.bash
if [[ ! -f "${APP_PATH}/.goose/namespace.bash" ]]; then
echo "${PROJECT_PATH}/.goose/namespace.bash is missing! Critical dependency! Exiting..." >&2
exit 255
fi
source ${APP_PATH}/.goose/namespace.bash
function init () {
[[ -f ${PROJECT_PATH}/.env ]] && source ${PROJECT_PATH}/.env
}
function cleanup () {
return
}
# ================================================================================================
# MAIN
function main () {
init
find_root_namespace
run_namespace
cleanup
}
main