# Script to be executed before 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 "prepare"; fi; 
#
# Use this script to move files, as this is much faster here than in the docker container.

# save old node_modules and package-lock.json, these might cause problems with npm install
# in case different versions of node or operating systems are used, also for "prepare" run!
echo "saving node_modules and package-lock.json"
[ -d "${PROJECT}/node_modules" ] && mv "${PROJECT}/node_modules" "${CLIP}/node_modules"
[ -f "${PROJECT}/package.json" ] && cp "${PROJECT}/package.json" "${CLIP}/package.json.sik"
[ -f "${PROJECT}/package-lock.json" ] && mv "${PROJECT}/package-lock.json" "${CLIP}/package-lock.json"