TeaWeb/scripts/resolve_commands.sh

31 lines
726 B
Bash
Raw Normal View History

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