mirror of
https://github.com/avatao-content/test-tutorial-framework
synced 2024-11-14 16:07:18 +00:00
Refactor frontend stuff to libhack/frontend.sh
This commit is contained in:
parent
6248da24e7
commit
cdbae9f39e
14
hack/libhack/frontend.sh
Normal file
14
hack/libhack/frontend.sh
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
# Requires context:
|
||||||
|
# - FRONTEND_PATH: absolute path of frontend repo
|
||||||
|
# - CHALLENGE_PATH: absolute path of challenge repo
|
||||||
|
|
||||||
|
|
||||||
|
frontend::run() {
|
||||||
|
local frontend_in_challenge="${CHALLENGE_PATH}/solvable/frontend"
|
||||||
|
if [[ "$(find "${frontend_in_challenge}" | wc -l)" -gt 2 ]];then
|
||||||
|
cd "${frontend_in_challenge}"
|
||||||
|
else
|
||||||
|
cd "${FRONTEND_PATH}"
|
||||||
|
fi
|
||||||
|
yarn start
|
||||||
|
}
|
17
hack/tfw.sh
17
hack/tfw.sh
@ -18,23 +18,13 @@ FRONTEND_PATH="${TFW_PATH}/${FRONTEND_REPO}"
|
|||||||
|
|
||||||
source "${SCRIPT_DIR}/libhack/baseimage.sh"
|
source "${SCRIPT_DIR}/libhack/baseimage.sh"
|
||||||
source "${SCRIPT_DIR}/libhack/challenge.sh"
|
source "${SCRIPT_DIR}/libhack/challenge.sh"
|
||||||
|
source "${SCRIPT_DIR}/libhack/frontend.sh"
|
||||||
|
|
||||||
|
|
||||||
run_frontend() {
|
|
||||||
FRONTEND_IN_CHALLENGE="${CHALLENGE_PATH}/solvable/frontend"
|
|
||||||
if [ "$(find "$FRONTEND_IN_CHALLENGE" | wc -l)" -gt 2 ]
|
|
||||||
then
|
|
||||||
cd $FRONTEND_IN_CHALLENGE
|
|
||||||
else
|
|
||||||
cd $FRONTEND_PATH
|
|
||||||
fi
|
|
||||||
yarn start
|
|
||||||
}
|
|
||||||
|
|
||||||
start_challenge_and_frontend() {
|
start_challenge_and_frontend() {
|
||||||
trap 'exit' INT TERM
|
trap 'exit' INT TERM
|
||||||
trap 'kill 0' EXIT
|
trap 'kill 0' EXIT
|
||||||
[[ "${RUN_FRONTEND:-1}" == "1" ]] && run_frontend &
|
[[ "${RUN_FRONTEND:-1}" == "1" ]] && frontend::run &
|
||||||
[[ "${BUILD:-1}" == "1" ]] && challenge::build
|
[[ "${BUILD:-1}" == "1" ]] && challenge::build
|
||||||
challenge::run $@
|
challenge::run $@
|
||||||
wait
|
wait
|
||||||
@ -55,6 +45,9 @@ case ${1:-} in
|
|||||||
runcontainer)
|
runcontainer)
|
||||||
BUILD=0 RUN_FRONTEND=0 start_challenge_and_frontend ${@:2}
|
BUILD=0 RUN_FRONTEND=0 start_challenge_and_frontend ${@:2}
|
||||||
;;
|
;;
|
||||||
|
runfrontend)
|
||||||
|
frontend::run
|
||||||
|
;;
|
||||||
buildtfw)
|
buildtfw)
|
||||||
baseimage::build_if_exists
|
baseimage::build_if_exists
|
||||||
;;
|
;;
|
||||||
|
Loading…
Reference in New Issue
Block a user