Skip to content

Commit 2abb6bf

Browse files
Add script orchestrator.
1 parent ede1329 commit 2abb6bf

File tree

1 file changed

+46
-0
lines changed

1 file changed

+46
-0
lines changed

scripts/pj

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
#!/usr/bin/env bash
2+
3+
4+
#
5+
# NAVIGATE TO CORRECT DIRECTORY
6+
#
7+
8+
# start by going to script dir so all movements
9+
# from here are relative
10+
SCRIPT_DIR=`dirname $(realpath "$0")`
11+
cd $SCRIPT_DIR
12+
13+
14+
#
15+
# PARSE & RUN COMMANDS
16+
#
17+
18+
# check if expansion of $1 is null
19+
# from: https://stackoverflow.com/a/6482403
20+
if [ -z $1 ]; then
21+
echo 'A command must be given.'
22+
exit 1
23+
fi
24+
25+
function run {
26+
$1 ${@:2}
27+
28+
exit $?
29+
}
30+
31+
# first check hard-coded shortcuts
32+
if [[ $1 = "t" ]]; then
33+
run ./test ${@:2}
34+
fi
35+
if [[ $1 = "d" ]]; then
36+
run ./dev ${@:2}
37+
fi
38+
39+
# otherwise, search for exact match to script name
40+
for file in ./*; do
41+
file_name=${file#"./"}
42+
43+
if [[ $file_name = $1 ]]; then
44+
run $file ${@:2}
45+
fi
46+
done

0 commit comments

Comments
 (0)