TeaWeb/scripts/resolve_commands.sh

31 lines
722 B
Bash
Raw Normal View History

2018-10-28 22:59:15 +00:00
#!/usr/bin/env bash
function execute_tsc() {
execute_npm_command tsc $@
}
2018-10-28 22:59:15 +00:00
function execute_ttsc() {
execute_npm_command ttsc $@
}
2018-10-28 22:59:15 +00:00
function execute_npm_command() {
command_name=$1
command_variable="command_$command_name"
#echo "Variable names $command_variable"
2018-10-28 22:59:15 +00:00
if [ "${!command_variable}" == "" ]; then
node_bin=$(npm bin)
#echo "Node root ${node_bin}"
if [ ! -e "${node_bin}/${command_name}" ]; then
echo "Could not find \"$command_name\" command"
echo "May type npm install"
2018-10-28 22:59:15 +00:00
exit 1
fi
eval "${command_variable}=\"${node_bin}/${command_name}\""
2018-10-28 22:59:15 +00:00
fi
echo "Arguments: ${@:2}"
${!command_variable} ${@:2}
2018-10-28 22:59:15 +00:00
}