8000 Allow installer to install specific version · shyim/symfony-cli@4afc16a · GitHub
[go: up one dir, main page]

Skip to content

Commit 4afc16a

Browse files
committed
Allow installer to install specific version
1 parent fcb097c commit 4afc16a

File tree

1 file changed

+15
-6
lines changed

1 file changed

+15
-6
lines changed

installer/bash-installer

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,8 @@ CLI_CONFIG_DIR=".symfony5"
2222
CLI_EXECUTABLE="symfony"
2323
CLI_TMP_NAME="$CLI_EXECUTABLE-"$(date +"%s")
2424
CLI_NAME="Symfony CLI"
25-
CLI_DOWNLOAD_URL_PATTERN="https://github.com/symfony-cli/symfony-cli/releases/latest/download/symfony-cli_~platform~.tar.gz"
25+
CLI_VERSION="${CLI_VERSION:-latest}"
26+
CLI_DOWNLOAD_URL_PATTERN="https://github.com/symfony-cli/symfony-cli/releases/${CLI_VERSION}/download/symfony-cli_~platform~.tar.gz"
2627
CLI_TMPDIR="${TMPDIR:-/tmp}"
2728

2829
function output {
@@ -53,7 +54,6 @@ function output {
5354
}
5455

5556
output "${CLI_NAME} installer" "heading"
56-
5757
binary_dest="${HOME}/${CLI_CONFIG_DIR}/bin"
5858
custom_dir="false"
5959

@@ -79,6 +79,15 @@ case $1 in
7979
esac
8080
done
8181

82+
output "\nSanity check" "heading"
83+
84+
# Check that the version is valid
85+
if [[ $CLI_VERSION =~ '^[0-9]+(\.[0-9]+)*$' || $CLI_VERSION == 'latest' ]]; then
86+
output " [*] Version has valid format" "success"
87+
else
88+
output " [ ] ERROR: Version has invalid format." "error"
89+
fi
90+
8291
# Run environment checks.
8392
output "\nEnvironment check" "heading"
8493

@@ -163,14 +172,14 @@ platform="${kernel}_${machine}"
163172
# The necessary checks have passed. Start downloading the right version.
164173
output "\nDownload" "heading"
165174

166-
latest_url=${CLI_DOWNLOAD_URL_PATTERN/~platform~/${platform}}
167-
output " Downloading ${latest_url}...";
175+
version_url=${CLI_DOWNLOAD_URL_PATTERN/~platform~/${platform}}
176+
output " Downloading ${version_url}...";
168177
case $downloader in
169178
"curl")
170-
curl --fail --location "${latest_url}" > "${CLI_TMPDIR}/${CLI_TMP_NAME}.tar.gz"
179+
curl --fail --location "${version_url}" > "${CLI_TMPDIR}/${CLI_TMP_NAME}.tar.gz"
171180
;;
172181
"wget")
173-
wget -q --show-progress "${latest_url}" -O "${CLI_TMPDIR}/${CLI_TMP_NAME}.tar.gz"
182+
wget -q --show-progress "${version_url}" -O "${CLI_TMPDIR}/${CLI_TMP_NAME}.tar.gz"
174183
;;
175184
esac
176185

0 commit comments

Comments
 (0)
0