-
Notifications
You must be signed in to change notification settings - Fork 0
/
run
executable file
·34 lines (29 loc) · 937 Bytes
/
run
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
#!/bin/bash
# Make sure the caller provided a package/script entrypoint.
if [ -z "$1" ]; then
tput sgr 0; tput setaf 7; tput bold;
printf "\nERROR: "
tput sgr 0; tput setaf 1;
printf "You must specify a package/script as an entrypoint.\n\n"
tput sgr 0;
exit 1
fi
# Parse the incomng package/script path
IFS="/" read -r -a pkgScriptPath <<< "$1"
# Use the first package/script element as the Package Name.
packageName="${pkgScriptPath[0]}"
# Single-element package/script paths use Package Name as File Name.
# Otherwise, the second element is used as the File Name.
if [ -z ${pkgScriptPath[1]} ]; then
fileName="${pkgScriptPath[0]}"
else
fileName="${pkgScriptPath[1]}"
fi
# Craft the node execution statement
scriptPath="./packages/$packageName/lib/$fileName.js"
YELLOW='\033[0;93m'
NC='\033[0m'
printf "${YELLOW}Executing node ${scriptPath}${NC}\n\n"
# Use node to execute the script.
node "${scriptPath}"
echo ""