/
flutter
executable file
·37 lines (31 loc) · 1.05 KB
/
flutter
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
28
29
30
31
32
33
34
35
36
37
#!/usr/bin/env bash
# This script hijacks the flutter command.
# It prevents the switching of channels, because this needs to be done by downloading a channel from the archive.
# And it prevents doing an upgrade while the active Flutter version points to a versioned directory.
if ! command -v flutter-version &> /dev/null
then
echo "The flutter-version executable was not found"
exit 1
fi
if [[ $1 == "channel" ]]
then
echo "Switching channels is not allowed when using flutter-version"
exit 1
elif [[ $1 == "upgrade" ]]
then
# Make sure we are NOT in a versioned directory, like flutter-3.16.2
OUTPUT=`flutter-version versioned`
if [[ $OUTPUT == "1" ]]
then
echo "Upgrading a versioned Flutter directory is not allowed when using flutter-version"
exit 1
fi
fi
# Get the real flutter path and execute it with the provided arguments.
FLUTTER_CMD_PATH=`flutter-version path`
if [[ -z "$FLUTTER_CMD_PATH" ]]
then
echo "Cannot get the active flutter path from flutter-version"
exit 1
fi
eval $FLUTTER_CMD_PATH "$@"