-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy path.saint
80 lines (63 loc) · 2.55 KB
/
.saint
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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
#!/bin/bash
# saint Commands
# TODO: Let the user choose what he wants, automatically install everything(git clone projects), or manually (choose the path before clonning each)
# It is absolutely forbidden to change "BRAINILLO_FIRST_EXECUTION" variable name.
BRAINILLO_FIRST_EXECUTION=true
saint () {
# Config
if [ -n "$ZSH_VERSION" ]; then
local script_path=${(%):-%x}
PROJECT_PATH=$(dirname "${script_path}")
else
local script_path=${BASH_SOURCE[0]}
PROJECT_PATH=$(dirname "${script_path}")
fi
if [ -s "$PROJECT_PATH/.env" ]; then
export $(egrep -v '^#' ${PROJECT_PATH}/.env | xargs) > /dev/null
fi
# projectCommand should be used as a string to show the method command.
local projectCommand='saint'
# Adds saint custom Alias
source ${PROJECT_PATH}/.saintCustomAlias
# Other projects variables required
source ${PROJECT_PATH}/.saintVariables
# Required: Helpers
source ${PROJECT_PATH}/.saintHelpers
# Loading Projects
source ${PROJECT_PATH}/.saintProjects
# Required: Methods
source ${PROJECT_PATH}/.saintMethods
if test "${BRAINILLO_FIRST_EXECUTION}" = "false"; then
# Initialize the .saintMainCommands if it doesn't exist
if [ ! -f ${SAINT_METHODS_MAIN_COMMANDS_FILE} ]; then
saint_initialize_main_commands || \
saint_msg "${YELLOW}FATAL ERROR${NC} :: while initializing Saint." || return 1
if [ -f ${SAINT_METHODS_MAIN_COMMANDS_FILE} ]; then
source ${SAINT_METHODS_MAIN_COMMANDS_FILE}
else
saint_msg "${YELLOW}WARNING${NC} :: There is no main commands file to load yet."
fi;
else
source ${SAINT_METHODS_MAIN_COMMANDS_FILE}
fi;
fi;
# check first Execution - Because it will first load the function, then it'll load saint to check if it is really loaded.
if test "${BRAINILLO_FIRST_EXECUTION}" = "true"; then
# we need to check when openning saint if everything is set and ready.
if [ ! -f ${SAINT_METHODS_MAIN_COMMANDS_FILE} ]; then
saint_initialize_main_commands || \
saint_msg "${YELLOW}FATAL ERROR${NC} :: while initializing Saint."
if [ -f ${SAINT_METHODS_MAIN_COMMANDS_FILE} ]; then
source "${SAINT_METHODS_MAIN_COMMANDS_FILE}"
else
saint_msg "${YELLOW}WARNING${NC} :: There is no main commands file to load yet."
fi;
echo -e "Made the first setup and ${projectName} is ${GREEN}running${NC} 🤖"
BRAINILLO_FIRST_EXECUTION=false
else
echo -e "${projectName} is ${GREEN}running${NC} 🤖"
BRAINILLO_FIRST_EXECUTION=false
fi;
fi
};
saint