0
Fork 0
mirror of https://github.com/withastro/astro.git synced 2024-12-16 21:46:22 -05:00
astro/.gitpod/gitpod-setup.sh
Ofer Shaal 7088e86c64
Gitpod - fix pnpm version error (#4120)
* use Gitpod's node-LTS base image

* update gitpod command waiting for port

* export variables for pnpm

* install pnpm using recommended method

* fix prebuild's shell problem

* fix Gitpod ports await command syntax
2022-08-02 11:09:16 -05:00

27 lines
850 B
Bash
Executable file

#!/usr/bin/env bash
# Convert context URL to an array
mapfile -t CONTEXT_URL_ITEMS < <(echo "$GITPOD_WORKSPACE_CONTEXT_URL" | tr '/' '\n')
# Check if Gitpod started from a specific example directory in the repository
if [ "${CONTEXT_URL_ITEMS[7]}" = "examples" ]; then
EXAMPLE_PROJECT=${CONTEXT_URL_ITEMS[8]}
# Check it Gitpod started with $ASTRO_NEW environment variable
elif [ -n "$ASTRO_NEW" ]; then
EXAMPLE_PROJECT="$ASTRO_NEW"
# Otherwise, set the default example project - 'starter'
else
EXAMPLE_PROJECT="starter"
fi
# Wait for VSCode to be ready (port 23000)
gp ports await 23000 > /dev/null 2>&1
echo "Loading example project:" $EXAMPLE_PROJECT
# Go to the requested example project
cd "$GITPOD_REPO_ROOT"/examples/"$EXAMPLE_PROJECT" || exit
# Open the main page in VSCode
code src/pages/index.astro
# Start Astro
pnpm start