-
-
Notifications
You must be signed in to change notification settings - Fork 17
/
snuggsi
executable file
·79 lines (56 loc) · 1.76 KB
/
snuggsi
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
#!/usr/bin/env bash
set -u
# Environment variable vs. Shell Variable
# - https://askubuntu.com/questions/26318/environment-variable-vs-shell-variable-whats-the-difference
# Shell Parameter Expansion
# - https://www.gnu.org/software/bash/manual/html_node/Shell-Parameter-Expansion.html
# Bash string manipulations
# - http://www.tldp.org/LDP/LG/issue18/bash.html
# - https://stackoverflow.com/questions/6393551/what-is-the-meaning-of-0-in-a-bash-script
echo "
ツツツツツツツツツツツツツツツツツツツ
ツツツツツ ツツツツツ
ツツツツツ snuggsi ツ ツツツツツ
ツツツツツ ツツツツツ
ツツツツツツツツツツツツツツツツツツツ
"
function check {
local \
resource=$1
# Use -f to check file
test ! -d $resource \
&& echo -e " 🚫 RESOURCE NOT FOUND 👉 $resource\n\n" \
&& return 1
return 0
}
function run {
local \
snuggsi=$1
command=${snuggsi}/bin/${2:-help}
echo Local command ${command}
echo Resources ${RESOURCES[@]}
for resource in "${RESOURCES[@]}"
do
(check $resource) \
&& echo -e " 👉 📂 $resource ════════════════════\n\n" \
&& $command $resource
done
}
function snuggsi {
echo ${NODE_PATH}/${BASH_SOURCE##*/}
}
function command {
echo
# test ! -f $execute \
# || test ${execute##*/} == snuggsi \
# && echo -e "\n 🚫 NON EXECUTABLE COMMAND !\n\n" \
# && exit 1 # Short circuit execution
# echo $execute
}
declare -x \
NODE_PATH=${NODE_PATH:-`npm config get prefix | awk NR==1`/lib/node_modules} # {print;exit}`
declare -rx \
SNUGGSI=`snuggsi` \
COMMAND=$1
source $SNUGGSI/bin/.resources
run $SNUGGSI $COMMAND