Skip to content

Commit f5ddd6b

Browse files
committed
Don't maintain two build scripts
1 parent 7e619ff commit f5ddd6b

File tree

1 file changed

+8
-91
lines changed

1 file changed

+8
-91
lines changed

build.sh

Lines changed: 8 additions & 91 deletions
Original file line numberDiff line numberDiff line change
@@ -1,96 +1,13 @@
11
#!/usr/bin/env bash
22

3-
# Define directories.
4-
SCRIPT_DIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )
5-
TOOLS_DIR=$SCRIPT_DIR/tools
6-
7-
# Make sure the tools folder exist.
8-
if [ ! -d "$TOOLS_DIR" ]; then
9-
mkdir "$TOOLS_DIR"
10-
fi
11-
12-
#!/usr/bin/env bash
13-
# Define varibles
14-
SCRIPT_DIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )
15-
source $SCRIPT_DIR/build.config
16-
TOOLS_DIR=$SCRIPT_DIR/tools
17-
BROWSERS_DIR=$SCRIPT_DIR/tools/browsers
18-
CAKE_EXE=$TOOLS_DIR/dotnet-cake
19-
CAKE_PATH=$TOOLS_DIR/.store/cake.tool/$CAKE_VERSION
20-
21-
if [ "$CAKE_VERSION" = "" ] || [ "$DOTNET_VERSION" = "" ]; then
22-
echo "An error occured while parsing Cake / .NET Core SDK version."
23-
exit 1
24-
fi
25-
26-
# Make sure the tools folder exist.
27-
if [ ! -d "$TOOLS_DIR" ]; then
28-
mkdir "$TOOLS_DIR"
29-
fi
30-
31-
# Make sure the tools folder exist.
32-
if [ ! -d "$BROWSERS_DIR" ]; then
33-
mkdir "$BROWSERS_DIR"
34-
fi
35-
36-
export PLAYWRIGHT_BROWSERS_PATH=$BROWSERS_DIR
37-
38-
###########################################################################
39-
# INSTALL .NET CORE CLI
40-
###########################################################################
41-
42-
DOTNET_INSTALLED_VERSION=$(dotnet --version 2>&1)
43-
44-
if [ "$DOTNET_VERSION" != "$DOTNET_INSTALLED_VERSION" ]; then
45-
echo "Installing .NET CLI..."
46-
if [ ! -d "$SCRIPT_DIR/.dotnet" ]; then
47-
mkdir "$SCRIPT_DIR/.dotnet"
48-
fi
49-
curl -Lsfo "$SCRIPT_DIR/.dotnet/dotnet-install.sh" https://dot.net/v1/dotnet-install.sh
50-
bash "$SCRIPT_DIR/.dotnet/dotnet-install.sh" --version $DOTNET_VERSION --install-dir .dotnet --no-path
51-
export PATH="$SCRIPT_DIR/.dotnet":$PATH
52-
fi
53-
54-
export DOTNET_CLI_TELEMETRY_OPTOUT=1
55-
export DOTNET_SKIP_FIRST_TIME_EXPERIENCE=1
56-
57-
export DOTNET_ROOT=$SCRIPT_DIR/.dotnet
58-
59-
# Restore .NET tools
60-
dotnet tool restore
61-
62-
###########################################################################
63-
# INSTALL CAKE
64-
###########################################################################
65-
66-
CAKE_INSTALLED_VERSION=$(dotnet-cake --version 2>&1)
67-
68-
if [ "$CAKE_VERSION" != "$CAKE_INSTALLED_VERSION" ]; then
69-
if [ ! -f "$CAKE_EXE" ] || [ ! -d "$CAKE_PATH" ]; then
70-
if [ -f "$CAKE_EXE" ]; then
71-
dotnet tool uninstall --tool-path $TOOLS_DIR Cake.Tool
72-
fi
73-
74-
echo "Installing Cake $CAKE_VERSION..."
75-
dotnet tool install --tool-path $TOOLS_DIR --version $CAKE_VERSION Cake.Tool
76-
if [ $? -ne 0 ]; then
77-
echo "An error occured while installing Cake."
78-
exit 1
79-
fi
80-
fi
81-
82-
# Make sure that Cake has been installed.
83-
if [ ! -f "$CAKE_EXE" ]; then
84-
echo "Could not find Cake.exe at '$CAKE_EXE'."
85-
exit 1
86-
fi
87-
else
88-
CAKE_EXE="dotnet-cake"
3+
# Check if pwsh is available
4+
if ! command -v pwsh &> /dev/null; then
5+
echo "Error: 'pwsh' command not found. Please install PowerShell to proceed."
6+
exit 1
897
fi
908

91-
###########################################################################
92-
# RUN BUILD SCRIPT
93-
###########################################################################
9+
# Run pwsh with all arguments passed to this script
10+
pwsh "$@"
9411

95-
# Start Cake
96-
(exec "$CAKE_EXE" --bootstrap) && (exec "$CAKE_EXE" "$@")
12+
# Pass through the exit code of the pwsh command
13+
exit $?

0 commit comments

Comments
 (0)