# Script to be executed after docker container is started.
# This script is executed in the directory where the docker container is started, i.e. in the WORKSPACE.
#
# The following environment variables are available:
# - CLIP: the path to the CLIP directory
# - PROJECT: the path to the project directory
# - CHECK: the path to the check directory
# - PREPARE: if 1, then this is a "prepare" run (otherwise it's 0 and a "check" run)
#
# Hint: Use PREPARE as follows:
# 
#     if [ $PREPARE = 1 ]; then; echo "not prepare"; fi; 
#
# Use this script to move files, as this is much faster here than in the docker container.

# restore  node_modules and package-lock.json
echo "restoring node_modules and package-lock.json"
if [[ -f "${CLIP}/package.json.sik" ]]; then
    [ -f "${PROJECT}/package.json" ] && rm "${PROJECT}/package.json"
    mv "${CLIP}/package.json.sik" "${PROJECT}/package.json"
fi 
if [[ -f "${CLIP}/package-lock.json" ]]; then
    [ -f "${PROJECT}/package-lock.json" ] && rm "${PROJECT}/package-lock.json"
    mv "${CLIP}/package-lock.json" "${PROJECT}/package-lock.json"
fi 
if [[ -d "${CLIP}/node_modules" ]]; then
    [ -d "${PROJECT}/node_modules" ] && rm -rf "${PROJECT}/node_modules"
    mv "${CLIP}/node_modules" "${PROJECT}/node_modules"
fi