-
-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
anagram-exercise-fix: Added contents to the fetch-cobolcheck{,.ps1} f…
…iles. (#156) * anagram-exercise-fix: Added contents to the fetch-cobolcheck{,.ps1} files. * Add sync cobolcheck script (#157) * anagram-exercise-fix: Rebased to main and synced all fetch-cobolcheck files --------- Co-authored-by: Erik Schierboom <[email protected]>
- Loading branch information
1 parent
3ddeb0a
commit f2095c6
Showing
92 changed files
with
472 additions
and
728 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
#!/usr/bin/env bash | ||
|
||
# This file is inspired by https://github.com/exercism/configlet/blob/main/scripts/fetch-configlet. | ||
# It is only used in the cobol track, and a copy of it is placed in every exercise folder. | ||
# If you change something, make sure to upgrade all scripts in all exercises! | ||
|
||
set -eo pipefail | ||
|
||
readonly LATEST='https://api.github.com/repos/0xE282B0/cobol-check/releases/latest' | ||
|
||
case "$(uname)" in | ||
Darwin*) os='mac' ;; | ||
Linux*) os='linux' ;; | ||
Windows*) os='windows' ;; | ||
MINGW*) os='windows' ;; | ||
MSYS_NT-*) os='windows' ;; | ||
*) os='linux' ;; | ||
esac | ||
|
||
case "${os}" in | ||
windows*) ext='.exe' ;; | ||
*) ext='' ;; | ||
esac | ||
|
||
arch="$(uname -m)" | ||
|
||
curlopts=( | ||
--silent | ||
--show-error | ||
--fail | ||
--location | ||
--retry 3 | ||
) | ||
|
||
if [[ -n "${GITHUB_TOKEN}" ]]; then | ||
curlopts+=(--header "authorization: Bearer ${GITHUB_TOKEN}") | ||
fi | ||
|
||
suffix="${os}-${arch}${ext}" | ||
|
||
get_download_url() { | ||
curl "${curlopts[@]}" --header 'Accept: application/vnd.github.v3+json' "${LATEST}" | | ||
grep "\"browser_download_url\": \".*/download/.*/cobol-check.*${suffix}\"$" | | ||
cut -d'"' -f4 | ||
} | ||
|
||
main() { | ||
output_path="/usr/local/bin/cobolcheck${ext}" | ||
download_url="$(get_download_url)" | ||
curl "${curlopts[@]}" --output "${output_path}" "${download_url}" | ||
chmod +x "${output_path}" | ||
} | ||
|
||
main |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
# This file is inspired by https://github.com/exercism/configlet/blob/main/scripts/fetch-configlet.ps1. | ||
# It is only used in the cobol track, and a copy of it is placed in every exercise folder. | ||
# If you change something, make sure to upgrade all scripts in all exercises! | ||
|
||
$ErrorActionPreference = "Stop" | ||
$ProgressPreference = "SilentlyContinue" | ||
|
||
$requestOpts = @{ | ||
Headers = If ($env:GITHUB_TOKEN) { @{ Authorization = "Bearer ${env:GITHUB_TOKEN}" } } Else { @{ } } | ||
MaximumRetryCount = 3 | ||
RetryIntervalSec = 1 | ||
} | ||
|
||
$arch = If ([Environment]::Is64BitOperatingSystem) { "amd64" } Else { "x86" } | ||
$fileName = "cobol-check-windows-$arch.exe" | ||
|
||
Function Get-DownloadUrl { | ||
$latestUrl = "https://api.github.com/repos/0xE282B0/cobol-check/releases/latest" | ||
Invoke-RestMethod -Uri $latestUrl -PreserveAuthorizationOnRedirect @requestOpts | ||
| Select-Object -ExpandProperty assets | ||
| Where-Object { $_.browser_download_url -match $FileName } | ||
| Select-Object -ExpandProperty browser_download_url | ||
} | ||
|
||
$downloadUrl = Get-DownloadUrl | ||
$outputDir = Join-Path -Path $HOME -ChildPath "cobolcheck" | ||
$outputFile = Join-Path -Path $outputDir -ChildPath "cobolcheck.exe" | ||
New-Item -ItemType Directory -Path $outputDir -Force | Out-Null | ||
Invoke-WebRequest -Uri $downloadUrl -OutFile $outputFile @requestOpts |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.