aboutsummaryrefslogtreecommitdiff
path: root/.gitpod/gitpod-setup.sh
blob: 883b3b1c97f70676c6259032c028395cc110bd4f (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
#!/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 await-port 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