Skip to content

Commit

Permalink
Correctly cd into directory when needed
Browse files Browse the repository at this point in the history
  • Loading branch information
SleeplessByte committed Aug 11, 2024
1 parent 21ec568 commit 414a81c
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions bin/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,8 @@ if test -f "${OUTPUT}.npmrc"; then
mv "${OUTPUT}.npmrc" "${OUTPUT}.npmrc.πŸ’₯.bak" || true
fi;

COREPACK_ROOT_DIR=$(pwd)

if [[ "${OUTPUT}" =~ "$ROOT" ]]; then
echo ""
echo "The output directory seems to be placed inside the test "
Expand All @@ -177,6 +179,8 @@ else
echo "standalone package."
echo ""

COREPACK_ROOT_DIR="${OUTPUT}"

echo "βœ”οΈ pnpm cache from root to output"
# cd $ROOT && corepack pnpm deploy --filter @exercism/javascript-test-runner --ignore-scripts "${OUTPUT}deploy"
# mv "${OUTPUT}deploy/node_modules" "${OUTPUT}"
Expand Down Expand Up @@ -315,13 +319,13 @@ if test -f "${OUTPUT}package.json"; then
ls -aln1 "${OUTPUT}node_modules/.bin"
else
echo ".pnpm hoisted packages not found"
cd "${OUTPUT}" && corepack pnpm install --offline --frozen-lockfile
cd "${COREPACK_ROOT_DIR}" && corepack pnpm install --offline --frozen-lockfile
fi
fi;

bin_jest="$(corepack pnpm bin)/jest"
bin_jest="$(cd "${COREPACK_ROOT_DIR}" && corepack pnpm bin)/jest"
if [[ -f "${bin_jest}" && -x $(realpath "${bin_jest}") ]]; then
echo "βœ”οΈ jest executable found"
echo "βœ”οΈ jest executable found using ${bin_jest}"
else
echo "πŸ’₯ jest executable missing at ${bin_jest} or not executable"
echo "πŸ‘οΈ ${bin_jest} -> $(realpath "${bin_jest}")"
Expand All @@ -337,7 +341,7 @@ echo " ➀ Execution (tests: does the solution work?) "
echo "β•šβ•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•"
echo ""

jest_tests=$(corepack pnpm jest "${OUTPUT}*" --listTests --passWithNoTests) || false
jest_tests=$(cd "${COREPACK_ROOT_DIR}" && corepack pnpm jest "${OUTPUT}*" --listTests --passWithNoTests) || false

if [ -z "${jest_tests}" ]; then
echo "❌ no jest tests (*.spec.js) discovered."
Expand Down Expand Up @@ -399,7 +403,7 @@ echo ""
echo "βš™οΈ corepack pnpm jest <...>"
echo ""

corepack pnpm jest "${OUTPUT}*" \
cd "${COREPACK_ROOT_DIR}" && corepack pnpm jest "${OUTPUT}*" \
--bail 1 \
--ci \
--colors \
Expand Down

0 comments on commit 414a81c

Please sign in to comment.