-
-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: install bashunit using bashdep
- Loading branch information
1 parent
8412a6f
commit 58bf024
Showing
3 changed files
with
79 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
#!/bin/bash | ||
|
||
# Ensure bashdep is installed | ||
[ ! -f lib/bashdep ] && { | ||
mkdir -p lib | ||
curl -sLo lib/bashdep \ | ||
https://github.com/Chemaclass/bashdep/releases/download/0.1/bashdep | ||
chmod +x lib/bashdep | ||
} | ||
|
||
# Add latest bashunit release to your dependencies | ||
DEPENDENCIES=( | ||
"https://github.com/TypedDevs/bashunit/releases/download/0.18.0/bashunit" | ||
"https://github.com/Chemaclass/bash-dumper/releases/download/0.1/dumper.sh@dev" | ||
) | ||
|
||
# Load, configure and run bashdep | ||
source lib/bashdep | ||
bashdep::setup dir="lib" dev-dir="src/dev" silent=false | ||
bashdep::install "${DEPENDENCIES[@]}" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
#!/bin/bash | ||
|
||
# Pass in any number of ANSI SGR codes. | ||
# | ||
# Code reference: | ||
# https://en.wikipedia.org/wiki/ANSI_escape_code#SGR_(Select_Graphic_Rendition)_parameters | ||
# Credit: | ||
# https://superuser.com/a/1119396 | ||
sgr() { | ||
local codes=${1:-0} | ||
shift | ||
|
||
for c in "$@"; do | ||
codes="$codes;$c" | ||
done | ||
|
||
echo $'\e'"[${codes}m" | ||
} | ||
|
||
_COLOR_BOLD="$(sgr 1)" | ||
_COLOR_FAINT="$(sgr 2)" | ||
_COLOR_RED="$(sgr 31)" | ||
_COLOR_YELLOW="$(sgr 33)" | ||
_COLOR_BLACK="$(sgr 30)" | ||
_COLOR_GREEN="$(sgr 32)" | ||
_COLOR_DEFAULT="$(sgr 0)" | ||
|
||
function trace() { | ||
set -x | ||
} | ||
|
||
function untrace() { | ||
set +x | ||
} | ||
|
||
# An alternative to echo when debugging. | ||
function dump() { | ||
printf "[%s] %s: %s\n" "${_COLOR_YELLOW}DUMP${_COLOR_DEFAULT}" \ | ||
"${_COLOR_GREEN}${BASH_SOURCE[1]}:${BASH_LINENO[0]}" \ | ||
"${_COLOR_DEFAULT}$*" | ||
} | ||
|
||
# Dump and Die. | ||
function dd() { | ||
printf "[%s] %s: %s\n" "${_COLOR_RED}DUMP${_COLOR_DEFAULT}" \ | ||
"${_COLOR_GREEN}${BASH_SOURCE[1]}:${BASH_LINENO[0]}" \ | ||
"${_COLOR_DEFAULT}$*" | ||
|
||
kill -9 $$ | ||
} | ||
|
||
function debug_var() { | ||
local var_name=$1 | ||
local var_value=${!var_name} | ||
printf "[%s] %s: %s=%s\n" "${_COLOR_FAINT}DEBUG${_COLOR_DEFAULT}" \ | ||
"${_COLOR_GREEN}${BASH_SOURCE[1]}:${BASH_LINENO[0]}" \ | ||
"$var_name" "$var_value" | ||
} |