#!/bin/bash
set -e
echo "copy source code..."
prebuilts_path=${9}
if [ "${8}" == 'true' ];then
if [ "${12}" == 'true' ];then
cp -R ${11} $7
fi
else
if [ "${12}" == 'true' ];then
cp -r ${11} $7
fi
fi
cp -f $4 $7
if [ -d "$prebuilts_path" ]; then
echo "copy node_modules..."
if [ "${9}" == 'true' ];then
cp -R $3 $7
else
cp -r $3 $7
fi
else
echo "download node_modules..."
npm install
cp -r ./node_modules ../../tools_previewer/automock/mock-generate
fi
cp -f $5 $7
cp -f $6 $7
cp -f $1 $7
cp -f ${13} $7
if [ -d "$prebuilts_path" ]; then
echo "prebuilts exists"
rm -rf "$7/current"
link_path=$(realpath $2)
ln -s $link_path "$7/current"
cd $7
if [ "${8}" == 'true' ];then
if [ "${12}" == 'true' ];then
./current/bin/node --max-old-space-size=4096 ./mock-generate/build.js ${10}
fi
./current/bin/node --max-old-space-size=4096 build_jsmock_system_plugin.js || exit 1 &
wait
else
if [ "${12}" == 'true' ];then
./current/bin/node --max-old-space-size=4096 ./mock-generate/build.js ${10}
fi
./current/bin/node --max-old-space-size=4096 build_jsmock_system_plugin.js || exit 1 &
wait
fi
else
npm run build
fi
rm -rf ./node_modules
if [ "${8}" == 'true' ];then
rm -rf ./current
else
rm -rf ./current
fi
rm -rf ./runtime
rm -rf ./tsconfig.json
rm -rf build_jsmock_system_plugin.js
rm -rf ./.eslintrc
rm -rf ./.babelrc
rm -rf ./package.json
if [ "${12}" == 'true' ];then
rm -rf ./mock-generate
fi