Skip to content

Commit

Permalink
perf(Bash): abstract functions into common.sh
Browse files Browse the repository at this point in the history
  • Loading branch information
johnnymillergh committed Oct 26, 2020
1 parent c7e2c2a commit 5e3fc6f
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 51 deletions.
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ install: skip
before_script:
- NOW=$(date +%Y-%m-%d' '%H:%M:%S.%N | cut -b 1-23)
- echo "$NOW INFO --- [INSTALL] Grant execute permission"
- chmod +x .travis/common.sh
- chmod +x .travis/install.sh
- chmod +x .travis/deploy.sh
- chmod +x mvnw
Expand Down
26 changes: 2 additions & 24 deletions .travis/deploy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,30 +11,8 @@
# https://stackoverflow.com/questions/19622198/what-does-set-e-mean-in-a-bash-script
set -e

########################## Functions Declaration ##########################
# Bash tips: Colors and formatting (ANSI/VT100 Control sequences)
# https://misc.flogisoft.com/bash/tip_colors_and_formatting
# Pass arguments into a function
# https://bash.cyberciti.biz/guide/Pass_arguments_into_a_function
function now() {
nowVariable=$(date +%Y-%m-%d' '%H:%M:%S.%N | cut -b 1-23)
echo "$nowVariable"
}

function printInfo() {
echo -e "$(now) \e[32m INFO --- $1\e[0m"
return 0
}

function printWarn() {
echo -e "$(now) \e[33m WARN --- $1\e[0m"
return 0
}

function printError() {
echo -e "$(now) \e[31mERROR --- $1\e[0m"
return 0
}
########################## Functions Import ##########################
source commond.sh

# Check the variables are set
if [ -z "$OSSRH_USERNAME" ]; then
Expand Down
29 changes: 2 additions & 27 deletions .travis/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,34 +4,9 @@
# https://stackoverflow.com/questions/19622198/what-does-set-e-mean-in-a-bash-script
set -e

NOW=$(date +%Y-%m-%d' '%H:%M:%S.%N | cut -b 1-23)
########################## Functions Import ##########################
source commond.sh

########################## Functions Declaration ##########################
# Bash tips: Colors and formatting (ANSI/VT100 Control sequences)
# https://misc.flogisoft.com/bash/tip_colors_and_formatting
# Pass arguments into a function
# https://bash.cyberciti.biz/guide/Pass_arguments_into_a_function
function now() {
nowVariable=$(date +%Y-%m-%d' '%H:%M:%S.%N | cut -b 1-23)
echo "$nowVariable"
}

function printInfo() {
echo -e "$(now) \e[32m INFO --- $1\e[0m"
return 0
}

function printWarn() {
echo -e "$(now) \e[33m WARN --- $1\e[0m"
return 0
}

function printError() {
echo -e "$(now) \e[31mERROR --- $1\e[0m"
return 0
}

########################## Functions Declaration ##########################
CURRENT_DIR=$(pwd)
printInfo "[INSTALL] CURRENT_DIR: $CURRENT_DIR"
command "ls"
Expand Down

0 comments on commit 5e3fc6f

Please sign in to comment.