#!/bin/sh
set -eo pipefail
DIR=$(pwd)
LIBRARY_DIR=${DIR%/}/library/
FILTERS_DIR=${DIR%/}/plugins/filters/
if [ "${MOLECULE_CUSTOM_MODULES_REPO}" ]; then
echo "Cloning custom modules..."
[ -d "${iLIBRARY_DIR}" ] && rm -rf "${LIBRARY_DIR}"
mkdir -p "${LIBRARY_DIR}"
git clone "${MOLECULE_CUSTOM_MODULES_REPO}" "{LIBRARY_DIR}" 2> /dev/null
echo
fi
if [ "${MOLECULE_CUSTOM_FILTERS_REPO}" ]; then
echo "Cloning custom filters..."
[ -d "${FILTERS_DIR}" ] && rm -rf "${FILTERS_DIR}"
mkdir -p "${FILTERS_DIR}"
git clone "$MOLECULE_CUSTOM_FILTERS_REPO" "${FILTERS_DIR}" 2> /dev/null
exec /usr/local/bin/molecule "$@"