diff --git a/bin/sync-fetch-cobolcheck-files b/bin/sync-fetch-cobolcheck-files new file mode 100755 index 00000000..6400e009 --- /dev/null +++ b/bin/sync-fetch-cobolcheck-files @@ -0,0 +1,10 @@ +#!/usr/bin/env bash + +set -euo pipefail + +shopt -s nullglob +for test_dir in exercises/{concept,practice}/*; do + for file in fetch-cobolcheck fetch-cobolcheck.ps1; do + cp "bin/${file}" "${test_dir}/bin/${file}" + done +done diff --git a/exercises/practice/acronym/bin/fetch-cobolcheck b/exercises/practice/acronym/bin/fetch-cobolcheck index 64230fe2..16c73077 100755 --- a/exercises/practice/acronym/bin/fetch-cobolcheck +++ b/exercises/practice/acronym/bin/fetch-cobolcheck @@ -1,10 +1,10 @@ #!/usr/bin/env bash -# This file is a copy of the -# https://github.com/exercism/configlet/blob/main/scripts/fetch-configlet file. -# Please submit bugfixes/improvements to the above file to ensure that all tracks benefit from the changes. +# 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 +set -eo pipefail readonly LATEST='https://api.github.com/repos/0xE282B0/cobol-check/releases/latest' @@ -45,16 +45,7 @@ get_download_url() { } main() { - if [[ -d ./bin ]]; then - output_dir="./bin" - elif [[ $PWD == */bin ]]; then - output_dir="$PWD" - else - echo "Error: no ./bin directory found. This script should be ran from a repo root." >&2 - return 1 - fi - - output_path="${output_dir}/cobolcheck${ext}" + output_path="/usr/local/bin/cobolcheck${ext}" download_url="$(get_download_url)" curl "${curlopts[@]}" --output "${output_path}" "${download_url}" chmod +x "${output_path}" diff --git a/exercises/practice/acronym/bin/fetch-cobolcheck.ps1 b/exercises/practice/acronym/bin/fetch-cobolcheck.ps1 index 261f5f45..3e9608d1 100644 --- a/exercises/practice/acronym/bin/fetch-cobolcheck.ps1 +++ b/exercises/practice/acronym/bin/fetch-cobolcheck.ps1 @@ -1,7 +1,6 @@ -# This file is a copy of the -# https://github.com/exercism/configlet/blob/main/scripts/fetch-configlet.ps1 file. -# Please submit bugfixes/improvements to the above file to ensure that all tracks -# benefit from the changes. +# 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" @@ -24,5 +23,7 @@ Function Get-DownloadUrl { } $downloadUrl = Get-DownloadUrl -$outputFile = Join-Path -Path $PSScriptRoot -ChildPath "cobolcheck.exe" -Invoke-WebRequest -Uri $downloadUrl -OutFile $outputFile @requestOpts \ No newline at end of file +$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 diff --git a/exercises/practice/all-your-base/bin/fetch-cobolcheck b/exercises/practice/all-your-base/bin/fetch-cobolcheck index 64230fe2..16c73077 100755 --- a/exercises/practice/all-your-base/bin/fetch-cobolcheck +++ b/exercises/practice/all-your-base/bin/fetch-cobolcheck @@ -1,10 +1,10 @@ #!/usr/bin/env bash -# This file is a copy of the -# https://github.com/exercism/configlet/blob/main/scripts/fetch-configlet file. -# Please submit bugfixes/improvements to the above file to ensure that all tracks benefit from the changes. +# 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 +set -eo pipefail readonly LATEST='https://api.github.com/repos/0xE282B0/cobol-check/releases/latest' @@ -45,16 +45,7 @@ get_download_url() { } main() { - if [[ -d ./bin ]]; then - output_dir="./bin" - elif [[ $PWD == */bin ]]; then - output_dir="$PWD" - else - echo "Error: no ./bin directory found. This script should be ran from a repo root." >&2 - return 1 - fi - - output_path="${output_dir}/cobolcheck${ext}" + output_path="/usr/local/bin/cobolcheck${ext}" download_url="$(get_download_url)" curl "${curlopts[@]}" --output "${output_path}" "${download_url}" chmod +x "${output_path}" diff --git a/exercises/practice/all-your-base/bin/fetch-cobolcheck.ps1 b/exercises/practice/all-your-base/bin/fetch-cobolcheck.ps1 index 261f5f45..3e9608d1 100644 --- a/exercises/practice/all-your-base/bin/fetch-cobolcheck.ps1 +++ b/exercises/practice/all-your-base/bin/fetch-cobolcheck.ps1 @@ -1,7 +1,6 @@ -# This file is a copy of the -# https://github.com/exercism/configlet/blob/main/scripts/fetch-configlet.ps1 file. -# Please submit bugfixes/improvements to the above file to ensure that all tracks -# benefit from the changes. +# 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" @@ -24,5 +23,7 @@ Function Get-DownloadUrl { } $downloadUrl = Get-DownloadUrl -$outputFile = Join-Path -Path $PSScriptRoot -ChildPath "cobolcheck.exe" -Invoke-WebRequest -Uri $downloadUrl -OutFile $outputFile @requestOpts \ No newline at end of file +$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 diff --git a/exercises/practice/allergies/bin/fetch-cobolcheck b/exercises/practice/allergies/bin/fetch-cobolcheck index dd8159be..16c73077 100755 --- a/exercises/practice/allergies/bin/fetch-cobolcheck +++ b/exercises/practice/allergies/bin/fetch-cobolcheck @@ -45,16 +45,7 @@ get_download_url() { } main() { - if [[ -d ./bin ]]; then - output_dir="./bin" - elif [[ $PWD == */bin ]]; then - output_dir="$PWD" - else - echo "Error: no ./bin directory found. This script should be ran from a repo root." >&2 - return 1 - fi - - output_path="${output_dir}/cobolcheck${ext}" + output_path="/usr/local/bin/cobolcheck${ext}" download_url="$(get_download_url)" curl "${curlopts[@]}" --output "${output_path}" "${download_url}" chmod +x "${output_path}" diff --git a/exercises/practice/allergies/bin/fetch-cobolcheck.ps1 b/exercises/practice/allergies/bin/fetch-cobolcheck.ps1 index 65ca602d..3e9608d1 100644 --- a/exercises/practice/allergies/bin/fetch-cobolcheck.ps1 +++ b/exercises/practice/allergies/bin/fetch-cobolcheck.ps1 @@ -23,5 +23,7 @@ Function Get-DownloadUrl { } $downloadUrl = Get-DownloadUrl -$outputFile = Join-Path -Path $PSScriptRoot -ChildPath "cobolcheck.exe" -Invoke-WebRequest -Uri $downloadUrl -OutFile $outputFile @requestOpts \ No newline at end of file +$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 diff --git a/exercises/practice/anagram/bin/fetch-cobolcheck b/exercises/practice/anagram/bin/fetch-cobolcheck index e69de29b..16c73077 100755 --- a/exercises/practice/anagram/bin/fetch-cobolcheck +++ b/exercises/practice/anagram/bin/fetch-cobolcheck @@ -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 diff --git a/exercises/practice/anagram/bin/fetch-cobolcheck.ps1 b/exercises/practice/anagram/bin/fetch-cobolcheck.ps1 index e69de29b..3e9608d1 100644 --- a/exercises/practice/anagram/bin/fetch-cobolcheck.ps1 +++ b/exercises/practice/anagram/bin/fetch-cobolcheck.ps1 @@ -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 diff --git a/exercises/practice/armstrong-numbers/bin/fetch-cobolcheck b/exercises/practice/armstrong-numbers/bin/fetch-cobolcheck index dd8159be..16c73077 100755 --- a/exercises/practice/armstrong-numbers/bin/fetch-cobolcheck +++ b/exercises/practice/armstrong-numbers/bin/fetch-cobolcheck @@ -45,16 +45,7 @@ get_download_url() { } main() { - if [[ -d ./bin ]]; then - output_dir="./bin" - elif [[ $PWD == */bin ]]; then - output_dir="$PWD" - else - echo "Error: no ./bin directory found. This script should be ran from a repo root." >&2 - return 1 - fi - - output_path="${output_dir}/cobolcheck${ext}" + output_path="/usr/local/bin/cobolcheck${ext}" download_url="$(get_download_url)" curl "${curlopts[@]}" --output "${output_path}" "${download_url}" chmod +x "${output_path}" diff --git a/exercises/practice/armstrong-numbers/bin/fetch-cobolcheck.ps1 b/exercises/practice/armstrong-numbers/bin/fetch-cobolcheck.ps1 index 65ca602d..3e9608d1 100644 --- a/exercises/practice/armstrong-numbers/bin/fetch-cobolcheck.ps1 +++ b/exercises/practice/armstrong-numbers/bin/fetch-cobolcheck.ps1 @@ -23,5 +23,7 @@ Function Get-DownloadUrl { } $downloadUrl = Get-DownloadUrl -$outputFile = Join-Path -Path $PSScriptRoot -ChildPath "cobolcheck.exe" -Invoke-WebRequest -Uri $downloadUrl -OutFile $outputFile @requestOpts \ No newline at end of file +$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 diff --git a/exercises/practice/atbash-cipher/bin/fetch-cobolcheck b/exercises/practice/atbash-cipher/bin/fetch-cobolcheck index 64230fe2..16c73077 100755 --- a/exercises/practice/atbash-cipher/bin/fetch-cobolcheck +++ b/exercises/practice/atbash-cipher/bin/fetch-cobolcheck @@ -1,10 +1,10 @@ #!/usr/bin/env bash -# This file is a copy of the -# https://github.com/exercism/configlet/blob/main/scripts/fetch-configlet file. -# Please submit bugfixes/improvements to the above file to ensure that all tracks benefit from the changes. +# 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 +set -eo pipefail readonly LATEST='https://api.github.com/repos/0xE282B0/cobol-check/releases/latest' @@ -45,16 +45,7 @@ get_download_url() { } main() { - if [[ -d ./bin ]]; then - output_dir="./bin" - elif [[ $PWD == */bin ]]; then - output_dir="$PWD" - else - echo "Error: no ./bin directory found. This script should be ran from a repo root." >&2 - return 1 - fi - - output_path="${output_dir}/cobolcheck${ext}" + output_path="/usr/local/bin/cobolcheck${ext}" download_url="$(get_download_url)" curl "${curlopts[@]}" --output "${output_path}" "${download_url}" chmod +x "${output_path}" diff --git a/exercises/practice/atbash-cipher/bin/fetch-cobolcheck.ps1 b/exercises/practice/atbash-cipher/bin/fetch-cobolcheck.ps1 index 261f5f45..3e9608d1 100644 --- a/exercises/practice/atbash-cipher/bin/fetch-cobolcheck.ps1 +++ b/exercises/practice/atbash-cipher/bin/fetch-cobolcheck.ps1 @@ -1,7 +1,6 @@ -# This file is a copy of the -# https://github.com/exercism/configlet/blob/main/scripts/fetch-configlet.ps1 file. -# Please submit bugfixes/improvements to the above file to ensure that all tracks -# benefit from the changes. +# 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" @@ -24,5 +23,7 @@ Function Get-DownloadUrl { } $downloadUrl = Get-DownloadUrl -$outputFile = Join-Path -Path $PSScriptRoot -ChildPath "cobolcheck.exe" -Invoke-WebRequest -Uri $downloadUrl -OutFile $outputFile @requestOpts \ No newline at end of file +$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 diff --git a/exercises/practice/binary-search/bin/fetch-cobolcheck b/exercises/practice/binary-search/bin/fetch-cobolcheck index 64230fe2..16c73077 100755 --- a/exercises/practice/binary-search/bin/fetch-cobolcheck +++ b/exercises/practice/binary-search/bin/fetch-cobolcheck @@ -1,10 +1,10 @@ #!/usr/bin/env bash -# This file is a copy of the -# https://github.com/exercism/configlet/blob/main/scripts/fetch-configlet file. -# Please submit bugfixes/improvements to the above file to ensure that all tracks benefit from the changes. +# 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 +set -eo pipefail readonly LATEST='https://api.github.com/repos/0xE282B0/cobol-check/releases/latest' @@ -45,16 +45,7 @@ get_download_url() { } main() { - if [[ -d ./bin ]]; then - output_dir="./bin" - elif [[ $PWD == */bin ]]; then - output_dir="$PWD" - else - echo "Error: no ./bin directory found. This script should be ran from a repo root." >&2 - return 1 - fi - - output_path="${output_dir}/cobolcheck${ext}" + output_path="/usr/local/bin/cobolcheck${ext}" download_url="$(get_download_url)" curl "${curlopts[@]}" --output "${output_path}" "${download_url}" chmod +x "${output_path}" diff --git a/exercises/practice/binary-search/bin/fetch-cobolcheck.ps1 b/exercises/practice/binary-search/bin/fetch-cobolcheck.ps1 index 261f5f45..3e9608d1 100644 --- a/exercises/practice/binary-search/bin/fetch-cobolcheck.ps1 +++ b/exercises/practice/binary-search/bin/fetch-cobolcheck.ps1 @@ -1,7 +1,6 @@ -# This file is a copy of the -# https://github.com/exercism/configlet/blob/main/scripts/fetch-configlet.ps1 file. -# Please submit bugfixes/improvements to the above file to ensure that all tracks -# benefit from the changes. +# 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" @@ -24,5 +23,7 @@ Function Get-DownloadUrl { } $downloadUrl = Get-DownloadUrl -$outputFile = Join-Path -Path $PSScriptRoot -ChildPath "cobolcheck.exe" -Invoke-WebRequest -Uri $downloadUrl -OutFile $outputFile @requestOpts \ No newline at end of file +$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 diff --git a/exercises/practice/binary/bin/fetch-cobolcheck b/exercises/practice/binary/bin/fetch-cobolcheck index 64230fe2..16c73077 100755 --- a/exercises/practice/binary/bin/fetch-cobolcheck +++ b/exercises/practice/binary/bin/fetch-cobolcheck @@ -1,10 +1,10 @@ #!/usr/bin/env bash -# This file is a copy of the -# https://github.com/exercism/configlet/blob/main/scripts/fetch-configlet file. -# Please submit bugfixes/improvements to the above file to ensure that all tracks benefit from the changes. +# 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 +set -eo pipefail readonly LATEST='https://api.github.com/repos/0xE282B0/cobol-check/releases/latest' @@ -45,16 +45,7 @@ get_download_url() { } main() { - if [[ -d ./bin ]]; then - output_dir="./bin" - elif [[ $PWD == */bin ]]; then - output_dir="$PWD" - else - echo "Error: no ./bin directory found. This script should be ran from a repo root." >&2 - return 1 - fi - - output_path="${output_dir}/cobolcheck${ext}" + output_path="/usr/local/bin/cobolcheck${ext}" download_url="$(get_download_url)" curl "${curlopts[@]}" --output "${output_path}" "${download_url}" chmod +x "${output_path}" diff --git a/exercises/practice/binary/bin/fetch-cobolcheck.ps1 b/exercises/practice/binary/bin/fetch-cobolcheck.ps1 index 261f5f45..3e9608d1 100644 --- a/exercises/practice/binary/bin/fetch-cobolcheck.ps1 +++ b/exercises/practice/binary/bin/fetch-cobolcheck.ps1 @@ -1,7 +1,6 @@ -# This file is a copy of the -# https://github.com/exercism/configlet/blob/main/scripts/fetch-configlet.ps1 file. -# Please submit bugfixes/improvements to the above file to ensure that all tracks -# benefit from the changes. +# 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" @@ -24,5 +23,7 @@ Function Get-DownloadUrl { } $downloadUrl = Get-DownloadUrl -$outputFile = Join-Path -Path $PSScriptRoot -ChildPath "cobolcheck.exe" -Invoke-WebRequest -Uri $downloadUrl -OutFile $outputFile @requestOpts \ No newline at end of file +$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 diff --git a/exercises/practice/bob/bin/fetch-cobolcheck b/exercises/practice/bob/bin/fetch-cobolcheck index 64230fe2..16c73077 100755 --- a/exercises/practice/bob/bin/fetch-cobolcheck +++ b/exercises/practice/bob/bin/fetch-cobolcheck @@ -1,10 +1,10 @@ #!/usr/bin/env bash -# This file is a copy of the -# https://github.com/exercism/configlet/blob/main/scripts/fetch-configlet file. -# Please submit bugfixes/improvements to the above file to ensure that all tracks benefit from the changes. +# 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 +set -eo pipefail readonly LATEST='https://api.github.com/repos/0xE282B0/cobol-check/releases/latest' @@ -45,16 +45,7 @@ get_download_url() { } main() { - if [[ -d ./bin ]]; then - output_dir="./bin" - elif [[ $PWD == */bin ]]; then - output_dir="$PWD" - else - echo "Error: no ./bin directory found. This script should be ran from a repo root." >&2 - return 1 - fi - - output_path="${output_dir}/cobolcheck${ext}" + output_path="/usr/local/bin/cobolcheck${ext}" download_url="$(get_download_url)" curl "${curlopts[@]}" --output "${output_path}" "${download_url}" chmod +x "${output_path}" diff --git a/exercises/practice/bob/bin/fetch-cobolcheck.ps1 b/exercises/practice/bob/bin/fetch-cobolcheck.ps1 index 261f5f45..3e9608d1 100644 --- a/exercises/practice/bob/bin/fetch-cobolcheck.ps1 +++ b/exercises/practice/bob/bin/fetch-cobolcheck.ps1 @@ -1,7 +1,6 @@ -# This file is a copy of the -# https://github.com/exercism/configlet/blob/main/scripts/fetch-configlet.ps1 file. -# Please submit bugfixes/improvements to the above file to ensure that all tracks -# benefit from the changes. +# 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" @@ -24,5 +23,7 @@ Function Get-DownloadUrl { } $downloadUrl = Get-DownloadUrl -$outputFile = Join-Path -Path $PSScriptRoot -ChildPath "cobolcheck.exe" -Invoke-WebRequest -Uri $downloadUrl -OutFile $outputFile @requestOpts \ No newline at end of file +$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 diff --git a/exercises/practice/circular-buffer/bin/fetch-cobolcheck b/exercises/practice/circular-buffer/bin/fetch-cobolcheck index 64230fe2..16c73077 100755 --- a/exercises/practice/circular-buffer/bin/fetch-cobolcheck +++ b/exercises/practice/circular-buffer/bin/fetch-cobolcheck @@ -1,10 +1,10 @@ #!/usr/bin/env bash -# This file is a copy of the -# https://github.com/exercism/configlet/blob/main/scripts/fetch-configlet file. -# Please submit bugfixes/improvements to the above file to ensure that all tracks benefit from the changes. +# 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 +set -eo pipefail readonly LATEST='https://api.github.com/repos/0xE282B0/cobol-check/releases/latest' @@ -45,16 +45,7 @@ get_download_url() { } main() { - if [[ -d ./bin ]]; then - output_dir="./bin" - elif [[ $PWD == */bin ]]; then - output_dir="$PWD" - else - echo "Error: no ./bin directory found. This script should be ran from a repo root." >&2 - return 1 - fi - - output_path="${output_dir}/cobolcheck${ext}" + output_path="/usr/local/bin/cobolcheck${ext}" download_url="$(get_download_url)" curl "${curlopts[@]}" --output "${output_path}" "${download_url}" chmod +x "${output_path}" diff --git a/exercises/practice/circular-buffer/bin/fetch-cobolcheck.ps1 b/exercises/practice/circular-buffer/bin/fetch-cobolcheck.ps1 index 261f5f45..3e9608d1 100644 --- a/exercises/practice/circular-buffer/bin/fetch-cobolcheck.ps1 +++ b/exercises/practice/circular-buffer/bin/fetch-cobolcheck.ps1 @@ -1,7 +1,6 @@ -# This file is a copy of the -# https://github.com/exercism/configlet/blob/main/scripts/fetch-configlet.ps1 file. -# Please submit bugfixes/improvements to the above file to ensure that all tracks -# benefit from the changes. +# 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" @@ -24,5 +23,7 @@ Function Get-DownloadUrl { } $downloadUrl = Get-DownloadUrl -$outputFile = Join-Path -Path $PSScriptRoot -ChildPath "cobolcheck.exe" -Invoke-WebRequest -Uri $downloadUrl -OutFile $outputFile @requestOpts \ No newline at end of file +$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 diff --git a/exercises/practice/collatz-conjecture/bin/fetch-cobolcheck b/exercises/practice/collatz-conjecture/bin/fetch-cobolcheck index dd8159be..16c73077 100755 --- a/exercises/practice/collatz-conjecture/bin/fetch-cobolcheck +++ b/exercises/practice/collatz-conjecture/bin/fetch-cobolcheck @@ -45,16 +45,7 @@ get_download_url() { } main() { - if [[ -d ./bin ]]; then - output_dir="./bin" - elif [[ $PWD == */bin ]]; then - output_dir="$PWD" - else - echo "Error: no ./bin directory found. This script should be ran from a repo root." >&2 - return 1 - fi - - output_path="${output_dir}/cobolcheck${ext}" + output_path="/usr/local/bin/cobolcheck${ext}" download_url="$(get_download_url)" curl "${curlopts[@]}" --output "${output_path}" "${download_url}" chmod +x "${output_path}" diff --git a/exercises/practice/collatz-conjecture/bin/fetch-cobolcheck.ps1 b/exercises/practice/collatz-conjecture/bin/fetch-cobolcheck.ps1 index 65ca602d..3e9608d1 100644 --- a/exercises/practice/collatz-conjecture/bin/fetch-cobolcheck.ps1 +++ b/exercises/practice/collatz-conjecture/bin/fetch-cobolcheck.ps1 @@ -23,5 +23,7 @@ Function Get-DownloadUrl { } $downloadUrl = Get-DownloadUrl -$outputFile = Join-Path -Path $PSScriptRoot -ChildPath "cobolcheck.exe" -Invoke-WebRequest -Uri $downloadUrl -OutFile $outputFile @requestOpts \ No newline at end of file +$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 diff --git a/exercises/practice/complex-numbers/bin/fetch-cobolcheck b/exercises/practice/complex-numbers/bin/fetch-cobolcheck index 64230fe2..16c73077 100755 --- a/exercises/practice/complex-numbers/bin/fetch-cobolcheck +++ b/exercises/practice/complex-numbers/bin/fetch-cobolcheck @@ -1,10 +1,10 @@ #!/usr/bin/env bash -# This file is a copy of the -# https://github.com/exercism/configlet/blob/main/scripts/fetch-configlet file. -# Please submit bugfixes/improvements to the above file to ensure that all tracks benefit from the changes. +# 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 +set -eo pipefail readonly LATEST='https://api.github.com/repos/0xE282B0/cobol-check/releases/latest' @@ -45,16 +45,7 @@ get_download_url() { } main() { - if [[ -d ./bin ]]; then - output_dir="./bin" - elif [[ $PWD == */bin ]]; then - output_dir="$PWD" - else - echo "Error: no ./bin directory found. This script should be ran from a repo root." >&2 - return 1 - fi - - output_path="${output_dir}/cobolcheck${ext}" + output_path="/usr/local/bin/cobolcheck${ext}" download_url="$(get_download_url)" curl "${curlopts[@]}" --output "${output_path}" "${download_url}" chmod +x "${output_path}" diff --git a/exercises/practice/complex-numbers/bin/fetch-cobolcheck.ps1 b/exercises/practice/complex-numbers/bin/fetch-cobolcheck.ps1 index 261f5f45..3e9608d1 100644 --- a/exercises/practice/complex-numbers/bin/fetch-cobolcheck.ps1 +++ b/exercises/practice/complex-numbers/bin/fetch-cobolcheck.ps1 @@ -1,7 +1,6 @@ -# This file is a copy of the -# https://github.com/exercism/configlet/blob/main/scripts/fetch-configlet.ps1 file. -# Please submit bugfixes/improvements to the above file to ensure that all tracks -# benefit from the changes. +# 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" @@ -24,5 +23,7 @@ Function Get-DownloadUrl { } $downloadUrl = Get-DownloadUrl -$outputFile = Join-Path -Path $PSScriptRoot -ChildPath "cobolcheck.exe" -Invoke-WebRequest -Uri $downloadUrl -OutFile $outputFile @requestOpts \ No newline at end of file +$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 diff --git a/exercises/practice/darts/bin/fetch-cobolcheck b/exercises/practice/darts/bin/fetch-cobolcheck index 64230fe2..16c73077 100755 --- a/exercises/practice/darts/bin/fetch-cobolcheck +++ b/exercises/practice/darts/bin/fetch-cobolcheck @@ -1,10 +1,10 @@ #!/usr/bin/env bash -# This file is a copy of the -# https://github.com/exercism/configlet/blob/main/scripts/fetch-configlet file. -# Please submit bugfixes/improvements to the above file to ensure that all tracks benefit from the changes. +# 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 +set -eo pipefail readonly LATEST='https://api.github.com/repos/0xE282B0/cobol-check/releases/latest' @@ -45,16 +45,7 @@ get_download_url() { } main() { - if [[ -d ./bin ]]; then - output_dir="./bin" - elif [[ $PWD == */bin ]]; then - output_dir="$PWD" - else - echo "Error: no ./bin directory found. This script should be ran from a repo root." >&2 - return 1 - fi - - output_path="${output_dir}/cobolcheck${ext}" + output_path="/usr/local/bin/cobolcheck${ext}" download_url="$(get_download_url)" curl "${curlopts[@]}" --output "${output_path}" "${download_url}" chmod +x "${output_path}" diff --git a/exercises/practice/darts/bin/fetch-cobolcheck.ps1 b/exercises/practice/darts/bin/fetch-cobolcheck.ps1 index 261f5f45..3e9608d1 100644 --- a/exercises/practice/darts/bin/fetch-cobolcheck.ps1 +++ b/exercises/practice/darts/bin/fetch-cobolcheck.ps1 @@ -1,7 +1,6 @@ -# This file is a copy of the -# https://github.com/exercism/configlet/blob/main/scripts/fetch-configlet.ps1 file. -# Please submit bugfixes/improvements to the above file to ensure that all tracks -# benefit from the changes. +# 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" @@ -24,5 +23,7 @@ Function Get-DownloadUrl { } $downloadUrl = Get-DownloadUrl -$outputFile = Join-Path -Path $PSScriptRoot -ChildPath "cobolcheck.exe" -Invoke-WebRequest -Uri $downloadUrl -OutFile $outputFile @requestOpts \ No newline at end of file +$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 diff --git a/exercises/practice/diamond/bin/fetch-cobolcheck b/exercises/practice/diamond/bin/fetch-cobolcheck index 64230fe2..16c73077 100755 --- a/exercises/practice/diamond/bin/fetch-cobolcheck +++ b/exercises/practice/diamond/bin/fetch-cobolcheck @@ -1,10 +1,10 @@ #!/usr/bin/env bash -# This file is a copy of the -# https://github.com/exercism/configlet/blob/main/scripts/fetch-configlet file. -# Please submit bugfixes/improvements to the above file to ensure that all tracks benefit from the changes. +# 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 +set -eo pipefail readonly LATEST='https://api.github.com/repos/0xE282B0/cobol-check/releases/latest' @@ -45,16 +45,7 @@ get_download_url() { } main() { - if [[ -d ./bin ]]; then - output_dir="./bin" - elif [[ $PWD == */bin ]]; then - output_dir="$PWD" - else - echo "Error: no ./bin directory found. This script should be ran from a repo root." >&2 - return 1 - fi - - output_path="${output_dir}/cobolcheck${ext}" + output_path="/usr/local/bin/cobolcheck${ext}" download_url="$(get_download_url)" curl "${curlopts[@]}" --output "${output_path}" "${download_url}" chmod +x "${output_path}" diff --git a/exercises/practice/diamond/bin/fetch-cobolcheck.ps1 b/exercises/practice/diamond/bin/fetch-cobolcheck.ps1 index 261f5f45..3e9608d1 100644 --- a/exercises/practice/diamond/bin/fetch-cobolcheck.ps1 +++ b/exercises/practice/diamond/bin/fetch-cobolcheck.ps1 @@ -1,7 +1,6 @@ -# This file is a copy of the -# https://github.com/exercism/configlet/blob/main/scripts/fetch-configlet.ps1 file. -# Please submit bugfixes/improvements to the above file to ensure that all tracks -# benefit from the changes. +# 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" @@ -24,5 +23,7 @@ Function Get-DownloadUrl { } $downloadUrl = Get-DownloadUrl -$outputFile = Join-Path -Path $PSScriptRoot -ChildPath "cobolcheck.exe" -Invoke-WebRequest -Uri $downloadUrl -OutFile $outputFile @requestOpts \ No newline at end of file +$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 diff --git a/exercises/practice/difference-of-squares/bin/fetch-cobolcheck b/exercises/practice/difference-of-squares/bin/fetch-cobolcheck index dd8159be..16c73077 100755 --- a/exercises/practice/difference-of-squares/bin/fetch-cobolcheck +++ b/exercises/practice/difference-of-squares/bin/fetch-cobolcheck @@ -45,16 +45,7 @@ get_download_url() { } main() { - if [[ -d ./bin ]]; then - output_dir="./bin" - elif [[ $PWD == */bin ]]; then - output_dir="$PWD" - else - echo "Error: no ./bin directory found. This script should be ran from a repo root." >&2 - return 1 - fi - - output_path="${output_dir}/cobolcheck${ext}" + output_path="/usr/local/bin/cobolcheck${ext}" download_url="$(get_download_url)" curl "${curlopts[@]}" --output "${output_path}" "${download_url}" chmod +x "${output_path}" diff --git a/exercises/practice/difference-of-squares/bin/fetch-cobolcheck.ps1 b/exercises/practice/difference-of-squares/bin/fetch-cobolcheck.ps1 index 65ca602d..3e9608d1 100644 --- a/exercises/practice/difference-of-squares/bin/fetch-cobolcheck.ps1 +++ b/exercises/practice/difference-of-squares/bin/fetch-cobolcheck.ps1 @@ -23,5 +23,7 @@ Function Get-DownloadUrl { } $downloadUrl = Get-DownloadUrl -$outputFile = Join-Path -Path $PSScriptRoot -ChildPath "cobolcheck.exe" -Invoke-WebRequest -Uri $downloadUrl -OutFile $outputFile @requestOpts \ No newline at end of file +$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 diff --git a/exercises/practice/eliuds-eggs/bin/fetch-cobolcheck b/exercises/practice/eliuds-eggs/bin/fetch-cobolcheck index 64230fe2..16c73077 100755 --- a/exercises/practice/eliuds-eggs/bin/fetch-cobolcheck +++ b/exercises/practice/eliuds-eggs/bin/fetch-cobolcheck @@ -1,10 +1,10 @@ #!/usr/bin/env bash -# This file is a copy of the -# https://github.com/exercism/configlet/blob/main/scripts/fetch-configlet file. -# Please submit bugfixes/improvements to the above file to ensure that all tracks benefit from the changes. +# 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 +set -eo pipefail readonly LATEST='https://api.github.com/repos/0xE282B0/cobol-check/releases/latest' @@ -45,16 +45,7 @@ get_download_url() { } main() { - if [[ -d ./bin ]]; then - output_dir="./bin" - elif [[ $PWD == */bin ]]; then - output_dir="$PWD" - else - echo "Error: no ./bin directory found. This script should be ran from a repo root." >&2 - return 1 - fi - - output_path="${output_dir}/cobolcheck${ext}" + output_path="/usr/local/bin/cobolcheck${ext}" download_url="$(get_download_url)" curl "${curlopts[@]}" --output "${output_path}" "${download_url}" chmod +x "${output_path}" diff --git a/exercises/practice/eliuds-eggs/bin/fetch-cobolcheck.ps1 b/exercises/practice/eliuds-eggs/bin/fetch-cobolcheck.ps1 index 261f5f45..3e9608d1 100644 --- a/exercises/practice/eliuds-eggs/bin/fetch-cobolcheck.ps1 +++ b/exercises/practice/eliuds-eggs/bin/fetch-cobolcheck.ps1 @@ -1,7 +1,6 @@ -# This file is a copy of the -# https://github.com/exercism/configlet/blob/main/scripts/fetch-configlet.ps1 file. -# Please submit bugfixes/improvements to the above file to ensure that all tracks -# benefit from the changes. +# 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" @@ -24,5 +23,7 @@ Function Get-DownloadUrl { } $downloadUrl = Get-DownloadUrl -$outputFile = Join-Path -Path $PSScriptRoot -ChildPath "cobolcheck.exe" -Invoke-WebRequest -Uri $downloadUrl -OutFile $outputFile @requestOpts \ No newline at end of file +$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 diff --git a/exercises/practice/grade-school/bin/fetch-cobolcheck b/exercises/practice/grade-school/bin/fetch-cobolcheck index 64230fe2..16c73077 100755 --- a/exercises/practice/grade-school/bin/fetch-cobolcheck +++ b/exercises/practice/grade-school/bin/fetch-cobolcheck @@ -1,10 +1,10 @@ #!/usr/bin/env bash -# This file is a copy of the -# https://github.com/exercism/configlet/blob/main/scripts/fetch-configlet file. -# Please submit bugfixes/improvements to the above file to ensure that all tracks benefit from the changes. +# 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 +set -eo pipefail readonly LATEST='https://api.github.com/repos/0xE282B0/cobol-check/releases/latest' @@ -45,16 +45,7 @@ get_download_url() { } main() { - if [[ -d ./bin ]]; then - output_dir="./bin" - elif [[ $PWD == */bin ]]; then - output_dir="$PWD" - else - echo "Error: no ./bin directory found. This script should be ran from a repo root." >&2 - return 1 - fi - - output_path="${output_dir}/cobolcheck${ext}" + output_path="/usr/local/bin/cobolcheck${ext}" download_url="$(get_download_url)" curl "${curlopts[@]}" --output "${output_path}" "${download_url}" chmod +x "${output_path}" diff --git a/exercises/practice/grade-school/bin/fetch-cobolcheck.ps1 b/exercises/practice/grade-school/bin/fetch-cobolcheck.ps1 index 261f5f45..3e9608d1 100644 --- a/exercises/practice/grade-school/bin/fetch-cobolcheck.ps1 +++ b/exercises/practice/grade-school/bin/fetch-cobolcheck.ps1 @@ -1,7 +1,6 @@ -# This file is a copy of the -# https://github.com/exercism/configlet/blob/main/scripts/fetch-configlet.ps1 file. -# Please submit bugfixes/improvements to the above file to ensure that all tracks -# benefit from the changes. +# 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" @@ -24,5 +23,7 @@ Function Get-DownloadUrl { } $downloadUrl = Get-DownloadUrl -$outputFile = Join-Path -Path $PSScriptRoot -ChildPath "cobolcheck.exe" -Invoke-WebRequest -Uri $downloadUrl -OutFile $outputFile @requestOpts \ No newline at end of file +$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 diff --git a/exercises/practice/hamming/bin/fetch-cobolcheck b/exercises/practice/hamming/bin/fetch-cobolcheck index dd8159be..16c73077 100755 --- a/exercises/practice/hamming/bin/fetch-cobolcheck +++ b/exercises/practice/hamming/bin/fetch-cobolcheck @@ -45,16 +45,7 @@ get_download_url() { } main() { - if [[ -d ./bin ]]; then - output_dir="./bin" - elif [[ $PWD == */bin ]]; then - output_dir="$PWD" - else - echo "Error: no ./bin directory found. This script should be ran from a repo root." >&2 - return 1 - fi - - output_path="${output_dir}/cobolcheck${ext}" + output_path="/usr/local/bin/cobolcheck${ext}" download_url="$(get_download_url)" curl "${curlopts[@]}" --output "${output_path}" "${download_url}" chmod +x "${output_path}" diff --git a/exercises/practice/hamming/bin/fetch-cobolcheck.ps1 b/exercises/practice/hamming/bin/fetch-cobolcheck.ps1 index 65ca602d..3e9608d1 100644 --- a/exercises/practice/hamming/bin/fetch-cobolcheck.ps1 +++ b/exercises/practice/hamming/bin/fetch-cobolcheck.ps1 @@ -23,5 +23,7 @@ Function Get-DownloadUrl { } $downloadUrl = Get-DownloadUrl -$outputFile = Join-Path -Path $PSScriptRoot -ChildPath "cobolcheck.exe" -Invoke-WebRequest -Uri $downloadUrl -OutFile $outputFile @requestOpts \ No newline at end of file +$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 diff --git a/exercises/practice/hello-world/bin/fetch-cobolcheck b/exercises/practice/hello-world/bin/fetch-cobolcheck index dd8159be..16c73077 100755 --- a/exercises/practice/hello-world/bin/fetch-cobolcheck +++ b/exercises/practice/hello-world/bin/fetch-cobolcheck @@ -45,16 +45,7 @@ get_download_url() { } main() { - if [[ -d ./bin ]]; then - output_dir="./bin" - elif [[ $PWD == */bin ]]; then - output_dir="$PWD" - else - echo "Error: no ./bin directory found. This script should be ran from a repo root." >&2 - return 1 - fi - - output_path="${output_dir}/cobolcheck${ext}" + output_path="/usr/local/bin/cobolcheck${ext}" download_url="$(get_download_url)" curl "${curlopts[@]}" --output "${output_path}" "${download_url}" chmod +x "${output_path}" diff --git a/exercises/practice/hello-world/bin/fetch-cobolcheck.ps1 b/exercises/practice/hello-world/bin/fetch-cobolcheck.ps1 index 65ca602d..3e9608d1 100644 --- a/exercises/practice/hello-world/bin/fetch-cobolcheck.ps1 +++ b/exercises/practice/hello-world/bin/fetch-cobolcheck.ps1 @@ -23,5 +23,7 @@ Function Get-DownloadUrl { } $downloadUrl = Get-DownloadUrl -$outputFile = Join-Path -Path $PSScriptRoot -ChildPath "cobolcheck.exe" -Invoke-WebRequest -Uri $downloadUrl -OutFile $outputFile @requestOpts \ No newline at end of file +$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 diff --git a/exercises/practice/high-scores/bin/fetch-cobolcheck b/exercises/practice/high-scores/bin/fetch-cobolcheck index dd8159be..16c73077 100755 --- a/exercises/practice/high-scores/bin/fetch-cobolcheck +++ b/exercises/practice/high-scores/bin/fetch-cobolcheck @@ -45,16 +45,7 @@ get_download_url() { } main() { - if [[ -d ./bin ]]; then - output_dir="./bin" - elif [[ $PWD == */bin ]]; then - output_dir="$PWD" - else - echo "Error: no ./bin directory found. This script should be ran from a repo root." >&2 - return 1 - fi - - output_path="${output_dir}/cobolcheck${ext}" + output_path="/usr/local/bin/cobolcheck${ext}" download_url="$(get_download_url)" curl "${curlopts[@]}" --output "${output_path}" "${download_url}" chmod +x "${output_path}" diff --git a/exercises/practice/high-scores/bin/fetch-cobolcheck.ps1 b/exercises/practice/high-scores/bin/fetch-cobolcheck.ps1 index 65ca602d..3e9608d1 100644 --- a/exercises/practice/high-scores/bin/fetch-cobolcheck.ps1 +++ b/exercises/practice/high-scores/bin/fetch-cobolcheck.ps1 @@ -23,5 +23,7 @@ Function Get-DownloadUrl { } $downloadUrl = Get-DownloadUrl -$outputFile = Join-Path -Path $PSScriptRoot -ChildPath "cobolcheck.exe" -Invoke-WebRequest -Uri $downloadUrl -OutFile $outputFile @requestOpts \ No newline at end of file +$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 diff --git a/exercises/practice/isogram/bin/fetch-cobolcheck b/exercises/practice/isogram/bin/fetch-cobolcheck index dd8159be..16c73077 100755 --- a/exercises/practice/isogram/bin/fetch-cobolcheck +++ b/exercises/practice/isogram/bin/fetch-cobolcheck @@ -45,16 +45,7 @@ get_download_url() { } main() { - if [[ -d ./bin ]]; then - output_dir="./bin" - elif [[ $PWD == */bin ]]; then - output_dir="$PWD" - else - echo "Error: no ./bin directory found. This script should be ran from a repo root." >&2 - return 1 - fi - - output_path="${output_dir}/cobolcheck${ext}" + output_path="/usr/local/bin/cobolcheck${ext}" download_url="$(get_download_url)" curl "${curlopts[@]}" --output "${output_path}" "${download_url}" chmod +x "${output_path}" diff --git a/exercises/practice/isogram/bin/fetch-cobolcheck.ps1 b/exercises/practice/isogram/bin/fetch-cobolcheck.ps1 index 65ca602d..3e9608d1 100644 --- a/exercises/practice/isogram/bin/fetch-cobolcheck.ps1 +++ b/exercises/practice/isogram/bin/fetch-cobolcheck.ps1 @@ -23,5 +23,7 @@ Function Get-DownloadUrl { } $downloadUrl = Get-DownloadUrl -$outputFile = Join-Path -Path $PSScriptRoot -ChildPath "cobolcheck.exe" -Invoke-WebRequest -Uri $downloadUrl -OutFile $outputFile @requestOpts \ No newline at end of file +$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 diff --git a/exercises/practice/knapsack/bin/fetch-cobolcheck b/exercises/practice/knapsack/bin/fetch-cobolcheck index 64230fe2..16c73077 100755 --- a/exercises/practice/knapsack/bin/fetch-cobolcheck +++ b/exercises/practice/knapsack/bin/fetch-cobolcheck @@ -1,10 +1,10 @@ #!/usr/bin/env bash -# This file is a copy of the -# https://github.com/exercism/configlet/blob/main/scripts/fetch-configlet file. -# Please submit bugfixes/improvements to the above file to ensure that all tracks benefit from the changes. +# 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 +set -eo pipefail readonly LATEST='https://api.github.com/repos/0xE282B0/cobol-check/releases/latest' @@ -45,16 +45,7 @@ get_download_url() { } main() { - if [[ -d ./bin ]]; then - output_dir="./bin" - elif [[ $PWD == */bin ]]; then - output_dir="$PWD" - else - echo "Error: no ./bin directory found. This script should be ran from a repo root." >&2 - return 1 - fi - - output_path="${output_dir}/cobolcheck${ext}" + output_path="/usr/local/bin/cobolcheck${ext}" download_url="$(get_download_url)" curl "${curlopts[@]}" --output "${output_path}" "${download_url}" chmod +x "${output_path}" diff --git a/exercises/practice/knapsack/bin/fetch-cobolcheck.ps1 b/exercises/practice/knapsack/bin/fetch-cobolcheck.ps1 index 261f5f45..3e9608d1 100644 --- a/exercises/practice/knapsack/bin/fetch-cobolcheck.ps1 +++ b/exercises/practice/knapsack/bin/fetch-cobolcheck.ps1 @@ -1,7 +1,6 @@ -# This file is a copy of the -# https://github.com/exercism/configlet/blob/main/scripts/fetch-configlet.ps1 file. -# Please submit bugfixes/improvements to the above file to ensure that all tracks -# benefit from the changes. +# 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" @@ -24,5 +23,7 @@ Function Get-DownloadUrl { } $downloadUrl = Get-DownloadUrl -$outputFile = Join-Path -Path $PSScriptRoot -ChildPath "cobolcheck.exe" -Invoke-WebRequest -Uri $downloadUrl -OutFile $outputFile @requestOpts \ No newline at end of file +$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 diff --git a/exercises/practice/leap/bin/fetch-cobolcheck b/exercises/practice/leap/bin/fetch-cobolcheck index dd8159be..16c73077 100755 --- a/exercises/practice/leap/bin/fetch-cobolcheck +++ b/exercises/practice/leap/bin/fetch-cobolcheck @@ -45,16 +45,7 @@ get_download_url() { } main() { - if [[ -d ./bin ]]; then - output_dir="./bin" - elif [[ $PWD == */bin ]]; then - output_dir="$PWD" - else - echo "Error: no ./bin directory found. This script should be ran from a repo root." >&2 - return 1 - fi - - output_path="${output_dir}/cobolcheck${ext}" + output_path="/usr/local/bin/cobolcheck${ext}" download_url="$(get_download_url)" curl "${curlopts[@]}" --output "${output_path}" "${download_url}" chmod +x "${output_path}" diff --git a/exercises/practice/leap/bin/fetch-cobolcheck.ps1 b/exercises/practice/leap/bin/fetch-cobolcheck.ps1 index 65ca602d..3e9608d1 100644 --- a/exercises/practice/leap/bin/fetch-cobolcheck.ps1 +++ b/exercises/practice/leap/bin/fetch-cobolcheck.ps1 @@ -23,5 +23,7 @@ Function Get-DownloadUrl { } $downloadUrl = Get-DownloadUrl -$outputFile = Join-Path -Path $PSScriptRoot -ChildPath "cobolcheck.exe" -Invoke-WebRequest -Uri $downloadUrl -OutFile $outputFile @requestOpts \ No newline at end of file +$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 diff --git a/exercises/practice/luhn/bin/fetch-cobolcheck b/exercises/practice/luhn/bin/fetch-cobolcheck index dd8159be..16c73077 100755 --- a/exercises/practice/luhn/bin/fetch-cobolcheck +++ b/exercises/practice/luhn/bin/fetch-cobolcheck @@ -45,16 +45,7 @@ get_download_url() { } main() { - if [[ -d ./bin ]]; then - output_dir="./bin" - elif [[ $PWD == */bin ]]; then - output_dir="$PWD" - else - echo "Error: no ./bin directory found. This script should be ran from a repo root." >&2 - return 1 - fi - - output_path="${output_dir}/cobolcheck${ext}" + output_path="/usr/local/bin/cobolcheck${ext}" download_url="$(get_download_url)" curl "${curlopts[@]}" --output "${output_path}" "${download_url}" chmod +x "${output_path}" diff --git a/exercises/practice/luhn/bin/fetch-cobolcheck.ps1 b/exercises/practice/luhn/bin/fetch-cobolcheck.ps1 index 65ca602d..3e9608d1 100644 --- a/exercises/practice/luhn/bin/fetch-cobolcheck.ps1 +++ b/exercises/practice/luhn/bin/fetch-cobolcheck.ps1 @@ -23,5 +23,7 @@ Function Get-DownloadUrl { } $downloadUrl = Get-DownloadUrl -$outputFile = Join-Path -Path $PSScriptRoot -ChildPath "cobolcheck.exe" -Invoke-WebRequest -Uri $downloadUrl -OutFile $outputFile @requestOpts \ No newline at end of file +$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 diff --git a/exercises/practice/matching-brackets/bin/fetch-cobolcheck b/exercises/practice/matching-brackets/bin/fetch-cobolcheck index 64230fe2..16c73077 100755 --- a/exercises/practice/matching-brackets/bin/fetch-cobolcheck +++ b/exercises/practice/matching-brackets/bin/fetch-cobolcheck @@ -1,10 +1,10 @@ #!/usr/bin/env bash -# This file is a copy of the -# https://github.com/exercism/configlet/blob/main/scripts/fetch-configlet file. -# Please submit bugfixes/improvements to the above file to ensure that all tracks benefit from the changes. +# 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 +set -eo pipefail readonly LATEST='https://api.github.com/repos/0xE282B0/cobol-check/releases/latest' @@ -45,16 +45,7 @@ get_download_url() { } main() { - if [[ -d ./bin ]]; then - output_dir="./bin" - elif [[ $PWD == */bin ]]; then - output_dir="$PWD" - else - echo "Error: no ./bin directory found. This script should be ran from a repo root." >&2 - return 1 - fi - - output_path="${output_dir}/cobolcheck${ext}" + output_path="/usr/local/bin/cobolcheck${ext}" download_url="$(get_download_url)" curl "${curlopts[@]}" --output "${output_path}" "${download_url}" chmod +x "${output_path}" diff --git a/exercises/practice/matching-brackets/bin/fetch-cobolcheck.ps1 b/exercises/practice/matching-brackets/bin/fetch-cobolcheck.ps1 index 261f5f45..3e9608d1 100644 --- a/exercises/practice/matching-brackets/bin/fetch-cobolcheck.ps1 +++ b/exercises/practice/matching-brackets/bin/fetch-cobolcheck.ps1 @@ -1,7 +1,6 @@ -# This file is a copy of the -# https://github.com/exercism/configlet/blob/main/scripts/fetch-configlet.ps1 file. -# Please submit bugfixes/improvements to the above file to ensure that all tracks -# benefit from the changes. +# 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" @@ -24,5 +23,7 @@ Function Get-DownloadUrl { } $downloadUrl = Get-DownloadUrl -$outputFile = Join-Path -Path $PSScriptRoot -ChildPath "cobolcheck.exe" -Invoke-WebRequest -Uri $downloadUrl -OutFile $outputFile @requestOpts \ No newline at end of file +$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 diff --git a/exercises/practice/meetup/bin/fetch-cobolcheck b/exercises/practice/meetup/bin/fetch-cobolcheck index 64230fe2..16c73077 100755 --- a/exercises/practice/meetup/bin/fetch-cobolcheck +++ b/exercises/practice/meetup/bin/fetch-cobolcheck @@ -1,10 +1,10 @@ #!/usr/bin/env bash -# This file is a copy of the -# https://github.com/exercism/configlet/blob/main/scripts/fetch-configlet file. -# Please submit bugfixes/improvements to the above file to ensure that all tracks benefit from the changes. +# 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 +set -eo pipefail readonly LATEST='https://api.github.com/repos/0xE282B0/cobol-check/releases/latest' @@ -45,16 +45,7 @@ get_download_url() { } main() { - if [[ -d ./bin ]]; then - output_dir="./bin" - elif [[ $PWD == */bin ]]; then - output_dir="$PWD" - else - echo "Error: no ./bin directory found. This script should be ran from a repo root." >&2 - return 1 - fi - - output_path="${output_dir}/cobolcheck${ext}" + output_path="/usr/local/bin/cobolcheck${ext}" download_url="$(get_download_url)" curl "${curlopts[@]}" --output "${output_path}" "${download_url}" chmod +x "${output_path}" diff --git a/exercises/practice/meetup/bin/fetch-cobolcheck.ps1 b/exercises/practice/meetup/bin/fetch-cobolcheck.ps1 index 261f5f45..3e9608d1 100644 --- a/exercises/practice/meetup/bin/fetch-cobolcheck.ps1 +++ b/exercises/practice/meetup/bin/fetch-cobolcheck.ps1 @@ -1,7 +1,6 @@ -# This file is a copy of the -# https://github.com/exercism/configlet/blob/main/scripts/fetch-configlet.ps1 file. -# Please submit bugfixes/improvements to the above file to ensure that all tracks -# benefit from the changes. +# 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" @@ -24,5 +23,7 @@ Function Get-DownloadUrl { } $downloadUrl = Get-DownloadUrl -$outputFile = Join-Path -Path $PSScriptRoot -ChildPath "cobolcheck.exe" -Invoke-WebRequest -Uri $downloadUrl -OutFile $outputFile @requestOpts \ No newline at end of file +$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 diff --git a/exercises/practice/nucleotide-count/bin/fetch-cobolcheck b/exercises/practice/nucleotide-count/bin/fetch-cobolcheck index dd8159be..16c73077 100755 --- a/exercises/practice/nucleotide-count/bin/fetch-cobolcheck +++ b/exercises/practice/nucleotide-count/bin/fetch-cobolcheck @@ -45,16 +45,7 @@ get_download_url() { } main() { - if [[ -d ./bin ]]; then - output_dir="./bin" - elif [[ $PWD == */bin ]]; then - output_dir="$PWD" - else - echo "Error: no ./bin directory found. This script should be ran from a repo root." >&2 - return 1 - fi - - output_path="${output_dir}/cobolcheck${ext}" + output_path="/usr/local/bin/cobolcheck${ext}" download_url="$(get_download_url)" curl "${curlopts[@]}" --output "${output_path}" "${download_url}" chmod +x "${output_path}" diff --git a/exercises/practice/nucleotide-count/bin/fetch-cobolcheck.ps1 b/exercises/practice/nucleotide-count/bin/fetch-cobolcheck.ps1 index 65ca602d..3e9608d1 100644 --- a/exercises/practice/nucleotide-count/bin/fetch-cobolcheck.ps1 +++ b/exercises/practice/nucleotide-count/bin/fetch-cobolcheck.ps1 @@ -23,5 +23,7 @@ Function Get-DownloadUrl { } $downloadUrl = Get-DownloadUrl -$outputFile = Join-Path -Path $PSScriptRoot -ChildPath "cobolcheck.exe" -Invoke-WebRequest -Uri $downloadUrl -OutFile $outputFile @requestOpts \ No newline at end of file +$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 diff --git a/exercises/practice/pangram/bin/fetch-cobolcheck b/exercises/practice/pangram/bin/fetch-cobolcheck index dd8159be..16c73077 100755 --- a/exercises/practice/pangram/bin/fetch-cobolcheck +++ b/exercises/practice/pangram/bin/fetch-cobolcheck @@ -45,16 +45,7 @@ get_download_url() { } main() { - if [[ -d ./bin ]]; then - output_dir="./bin" - elif [[ $PWD == */bin ]]; then - output_dir="$PWD" - else - echo "Error: no ./bin directory found. This script should be ran from a repo root." >&2 - return 1 - fi - - output_path="${output_dir}/cobolcheck${ext}" + output_path="/usr/local/bin/cobolcheck${ext}" download_url="$(get_download_url)" curl "${curlopts[@]}" --output "${output_path}" "${download_url}" chmod +x "${output_path}" diff --git a/exercises/practice/pangram/bin/fetch-cobolcheck.ps1 b/exercises/practice/pangram/bin/fetch-cobolcheck.ps1 index a57f708d..3e9608d1 100644 --- a/exercises/practice/pangram/bin/fetch-cobolcheck.ps1 +++ b/exercises/practice/pangram/bin/fetch-cobolcheck.ps1 @@ -23,5 +23,7 @@ Function Get-DownloadUrl { } $downloadUrl = Get-DownloadUrl -$outputFile = Join-Path -Path $PSScriptRoot -ChildPath "cobolcheck.exe" +$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 diff --git a/exercises/practice/pascals-triangle/bin/fetch-cobolcheck b/exercises/practice/pascals-triangle/bin/fetch-cobolcheck index 64230fe2..16c73077 100755 --- a/exercises/practice/pascals-triangle/bin/fetch-cobolcheck +++ b/exercises/practice/pascals-triangle/bin/fetch-cobolcheck @@ -1,10 +1,10 @@ #!/usr/bin/env bash -# This file is a copy of the -# https://github.com/exercism/configlet/blob/main/scripts/fetch-configlet file. -# Please submit bugfixes/improvements to the above file to ensure that all tracks benefit from the changes. +# 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 +set -eo pipefail readonly LATEST='https://api.github.com/repos/0xE282B0/cobol-check/releases/latest' @@ -45,16 +45,7 @@ get_download_url() { } main() { - if [[ -d ./bin ]]; then - output_dir="./bin" - elif [[ $PWD == */bin ]]; then - output_dir="$PWD" - else - echo "Error: no ./bin directory found. This script should be ran from a repo root." >&2 - return 1 - fi - - output_path="${output_dir}/cobolcheck${ext}" + output_path="/usr/local/bin/cobolcheck${ext}" download_url="$(get_download_url)" curl "${curlopts[@]}" --output "${output_path}" "${download_url}" chmod +x "${output_path}" diff --git a/exercises/practice/pascals-triangle/bin/fetch-cobolcheck.ps1 b/exercises/practice/pascals-triangle/bin/fetch-cobolcheck.ps1 index 261f5f45..3e9608d1 100644 --- a/exercises/practice/pascals-triangle/bin/fetch-cobolcheck.ps1 +++ b/exercises/practice/pascals-triangle/bin/fetch-cobolcheck.ps1 @@ -1,7 +1,6 @@ -# This file is a copy of the -# https://github.com/exercism/configlet/blob/main/scripts/fetch-configlet.ps1 file. -# Please submit bugfixes/improvements to the above file to ensure that all tracks -# benefit from the changes. +# 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" @@ -24,5 +23,7 @@ Function Get-DownloadUrl { } $downloadUrl = Get-DownloadUrl -$outputFile = Join-Path -Path $PSScriptRoot -ChildPath "cobolcheck.exe" -Invoke-WebRequest -Uri $downloadUrl -OutFile $outputFile @requestOpts \ No newline at end of file +$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 diff --git a/exercises/practice/pig-latin/bin/fetch-cobolcheck b/exercises/practice/pig-latin/bin/fetch-cobolcheck index 64230fe2..16c73077 100755 --- a/exercises/practice/pig-latin/bin/fetch-cobolcheck +++ b/exercises/practice/pig-latin/bin/fetch-cobolcheck @@ -1,10 +1,10 @@ #!/usr/bin/env bash -# This file is a copy of the -# https://github.com/exercism/configlet/blob/main/scripts/fetch-configlet file. -# Please submit bugfixes/improvements to the above file to ensure that all tracks benefit from the changes. +# 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 +set -eo pipefail readonly LATEST='https://api.github.com/repos/0xE282B0/cobol-check/releases/latest' @@ -45,16 +45,7 @@ get_download_url() { } main() { - if [[ -d ./bin ]]; then - output_dir="./bin" - elif [[ $PWD == */bin ]]; then - output_dir="$PWD" - else - echo "Error: no ./bin directory found. This script should be ran from a repo root." >&2 - return 1 - fi - - output_path="${output_dir}/cobolcheck${ext}" + output_path="/usr/local/bin/cobolcheck${ext}" download_url="$(get_download_url)" curl "${curlopts[@]}" --output "${output_path}" "${download_url}" chmod +x "${output_path}" diff --git a/exercises/practice/pig-latin/bin/fetch-cobolcheck.ps1 b/exercises/practice/pig-latin/bin/fetch-cobolcheck.ps1 index 261f5f45..3e9608d1 100644 --- a/exercises/practice/pig-latin/bin/fetch-cobolcheck.ps1 +++ b/exercises/practice/pig-latin/bin/fetch-cobolcheck.ps1 @@ -1,7 +1,6 @@ -# This file is a copy of the -# https://github.com/exercism/configlet/blob/main/scripts/fetch-configlet.ps1 file. -# Please submit bugfixes/improvements to the above file to ensure that all tracks -# benefit from the changes. +# 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" @@ -24,5 +23,7 @@ Function Get-DownloadUrl { } $downloadUrl = Get-DownloadUrl -$outputFile = Join-Path -Path $PSScriptRoot -ChildPath "cobolcheck.exe" -Invoke-WebRequest -Uri $downloadUrl -OutFile $outputFile @requestOpts \ No newline at end of file +$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 diff --git a/exercises/practice/protein-translation/bin/fetch-cobolcheck b/exercises/practice/protein-translation/bin/fetch-cobolcheck index 64230fe2..16c73077 100755 --- a/exercises/practice/protein-translation/bin/fetch-cobolcheck +++ b/exercises/practice/protein-translation/bin/fetch-cobolcheck @@ -1,10 +1,10 @@ #!/usr/bin/env bash -# This file is a copy of the -# https://github.com/exercism/configlet/blob/main/scripts/fetch-configlet file. -# Please submit bugfixes/improvements to the above file to ensure that all tracks benefit from the changes. +# 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 +set -eo pipefail readonly LATEST='https://api.github.com/repos/0xE282B0/cobol-check/releases/latest' @@ -45,16 +45,7 @@ get_download_url() { } main() { - if [[ -d ./bin ]]; then - output_dir="./bin" - elif [[ $PWD == */bin ]]; then - output_dir="$PWD" - else - echo "Error: no ./bin directory found. This script should be ran from a repo root." >&2 - return 1 - fi - - output_path="${output_dir}/cobolcheck${ext}" + output_path="/usr/local/bin/cobolcheck${ext}" download_url="$(get_download_url)" curl "${curlopts[@]}" --output "${output_path}" "${download_url}" chmod +x "${output_path}" diff --git a/exercises/practice/protein-translation/bin/fetch-cobolcheck.ps1 b/exercises/practice/protein-translation/bin/fetch-cobolcheck.ps1 index 1535c6e8..3e9608d1 100644 --- a/exercises/practice/protein-translation/bin/fetch-cobolcheck.ps1 +++ b/exercises/practice/protein-translation/bin/fetch-cobolcheck.ps1 @@ -1,7 +1,6 @@ -# This file is a copy of the -# https://github.com/exercism/configlet/blob/main/scripts/fetch-configlet.ps1 file. -# Please submit bugfixes/improvements to the above file to ensure that all tracks -# benefit from the changes. +# 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" @@ -24,5 +23,7 @@ Function Get-DownloadUrl { } $downloadUrl = Get-DownloadUrl -$outputFile = Join-Path -Path $PSScriptRoot -ChildPath "cobolcheck.exe" +$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 diff --git a/exercises/practice/queen-attack/bin/fetch-cobolcheck b/exercises/practice/queen-attack/bin/fetch-cobolcheck index 64230fe2..16c73077 100644 --- a/exercises/practice/queen-attack/bin/fetch-cobolcheck +++ b/exercises/practice/queen-attack/bin/fetch-cobolcheck @@ -1,10 +1,10 @@ #!/usr/bin/env bash -# This file is a copy of the -# https://github.com/exercism/configlet/blob/main/scripts/fetch-configlet file. -# Please submit bugfixes/improvements to the above file to ensure that all tracks benefit from the changes. +# 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 +set -eo pipefail readonly LATEST='https://api.github.com/repos/0xE282B0/cobol-check/releases/latest' @@ -45,16 +45,7 @@ get_download_url() { } main() { - if [[ -d ./bin ]]; then - output_dir="./bin" - elif [[ $PWD == */bin ]]; then - output_dir="$PWD" - else - echo "Error: no ./bin directory found. This script should be ran from a repo root." >&2 - return 1 - fi - - output_path="${output_dir}/cobolcheck${ext}" + output_path="/usr/local/bin/cobolcheck${ext}" download_url="$(get_download_url)" curl "${curlopts[@]}" --output "${output_path}" "${download_url}" chmod +x "${output_path}" diff --git a/exercises/practice/queen-attack/bin/fetch-cobolcheck.ps1 b/exercises/practice/queen-attack/bin/fetch-cobolcheck.ps1 index 261f5f45..3e9608d1 100644 --- a/exercises/practice/queen-attack/bin/fetch-cobolcheck.ps1 +++ b/exercises/practice/queen-attack/bin/fetch-cobolcheck.ps1 @@ -1,7 +1,6 @@ -# This file is a copy of the -# https://github.com/exercism/configlet/blob/main/scripts/fetch-configlet.ps1 file. -# Please submit bugfixes/improvements to the above file to ensure that all tracks -# benefit from the changes. +# 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" @@ -24,5 +23,7 @@ Function Get-DownloadUrl { } $downloadUrl = Get-DownloadUrl -$outputFile = Join-Path -Path $PSScriptRoot -ChildPath "cobolcheck.exe" -Invoke-WebRequest -Uri $downloadUrl -OutFile $outputFile @requestOpts \ No newline at end of file +$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 diff --git a/exercises/practice/raindrops/bin/fetch-cobolcheck b/exercises/practice/raindrops/bin/fetch-cobolcheck index dd8159be..16c73077 100755 --- a/exercises/practice/raindrops/bin/fetch-cobolcheck +++ b/exercises/practice/raindrops/bin/fetch-cobolcheck @@ -45,16 +45,7 @@ get_download_url() { } main() { - if [[ -d ./bin ]]; then - output_dir="./bin" - elif [[ $PWD == */bin ]]; then - output_dir="$PWD" - else - echo "Error: no ./bin directory found. This script should be ran from a repo root." >&2 - return 1 - fi - - output_path="${output_dir}/cobolcheck${ext}" + output_path="/usr/local/bin/cobolcheck${ext}" download_url="$(get_download_url)" curl "${curlopts[@]}" --output "${output_path}" "${download_url}" chmod +x "${output_path}" diff --git a/exercises/practice/raindrops/bin/fetch-cobolcheck.ps1 b/exercises/practice/raindrops/bin/fetch-cobolcheck.ps1 index 65ca602d..3e9608d1 100644 --- a/exercises/practice/raindrops/bin/fetch-cobolcheck.ps1 +++ b/exercises/practice/raindrops/bin/fetch-cobolcheck.ps1 @@ -23,5 +23,7 @@ Function Get-DownloadUrl { } $downloadUrl = Get-DownloadUrl -$outputFile = Join-Path -Path $PSScriptRoot -ChildPath "cobolcheck.exe" -Invoke-WebRequest -Uri $downloadUrl -OutFile $outputFile @requestOpts \ No newline at end of file +$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 diff --git a/exercises/practice/reverse-string/bin/fetch-cobolcheck b/exercises/practice/reverse-string/bin/fetch-cobolcheck index dd8159be..16c73077 100755 --- a/exercises/practice/reverse-string/bin/fetch-cobolcheck +++ b/exercises/practice/reverse-string/bin/fetch-cobolcheck @@ -45,16 +45,7 @@ get_download_url() { } main() { - if [[ -d ./bin ]]; then - output_dir="./bin" - elif [[ $PWD == */bin ]]; then - output_dir="$PWD" - else - echo "Error: no ./bin directory found. This script should be ran from a repo root." >&2 - return 1 - fi - - output_path="${output_dir}/cobolcheck${ext}" + output_path="/usr/local/bin/cobolcheck${ext}" download_url="$(get_download_url)" curl "${curlopts[@]}" --output "${output_path}" "${download_url}" chmod +x "${output_path}" diff --git a/exercises/practice/reverse-string/bin/fetch-cobolcheck.ps1 b/exercises/practice/reverse-string/bin/fetch-cobolcheck.ps1 index 65ca602d..3e9608d1 100644 --- a/exercises/practice/reverse-string/bin/fetch-cobolcheck.ps1 +++ b/exercises/practice/reverse-string/bin/fetch-cobolcheck.ps1 @@ -23,5 +23,7 @@ Function Get-DownloadUrl { } $downloadUrl = Get-DownloadUrl -$outputFile = Join-Path -Path $PSScriptRoot -ChildPath "cobolcheck.exe" -Invoke-WebRequest -Uri $downloadUrl -OutFile $outputFile @requestOpts \ No newline at end of file +$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 diff --git a/exercises/practice/rna-transcription/bin/fetch-cobolcheck b/exercises/practice/rna-transcription/bin/fetch-cobolcheck index dd8159be..16c73077 100755 --- a/exercises/practice/rna-transcription/bin/fetch-cobolcheck +++ b/exercises/practice/rna-transcription/bin/fetch-cobolcheck @@ -45,16 +45,7 @@ get_download_url() { } main() { - if [[ -d ./bin ]]; then - output_dir="./bin" - elif [[ $PWD == */bin ]]; then - output_dir="$PWD" - else - echo "Error: no ./bin directory found. This script should be ran from a repo root." >&2 - return 1 - fi - - output_path="${output_dir}/cobolcheck${ext}" + output_path="/usr/local/bin/cobolcheck${ext}" download_url="$(get_download_url)" curl "${curlopts[@]}" --output "${output_path}" "${download_url}" chmod +x "${output_path}" diff --git a/exercises/practice/rna-transcription/bin/fetch-cobolcheck.ps1 b/exercises/practice/rna-transcription/bin/fetch-cobolcheck.ps1 index 65ca602d..3e9608d1 100644 --- a/exercises/practice/rna-transcription/bin/fetch-cobolcheck.ps1 +++ b/exercises/practice/rna-transcription/bin/fetch-cobolcheck.ps1 @@ -23,5 +23,7 @@ Function Get-DownloadUrl { } $downloadUrl = Get-DownloadUrl -$outputFile = Join-Path -Path $PSScriptRoot -ChildPath "cobolcheck.exe" -Invoke-WebRequest -Uri $downloadUrl -OutFile $outputFile @requestOpts \ No newline at end of file +$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 diff --git a/exercises/practice/robot-simulator/bin/fetch-cobolcheck b/exercises/practice/robot-simulator/bin/fetch-cobolcheck index 64230fe2..16c73077 100755 --- a/exercises/practice/robot-simulator/bin/fetch-cobolcheck +++ b/exercises/practice/robot-simulator/bin/fetch-cobolcheck @@ -1,10 +1,10 @@ #!/usr/bin/env bash -# This file is a copy of the -# https://github.com/exercism/configlet/blob/main/scripts/fetch-configlet file. -# Please submit bugfixes/improvements to the above file to ensure that all tracks benefit from the changes. +# 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 +set -eo pipefail readonly LATEST='https://api.github.com/repos/0xE282B0/cobol-check/releases/latest' @@ -45,16 +45,7 @@ get_download_url() { } main() { - if [[ -d ./bin ]]; then - output_dir="./bin" - elif [[ $PWD == */bin ]]; then - output_dir="$PWD" - else - echo "Error: no ./bin directory found. This script should be ran from a repo root." >&2 - return 1 - fi - - output_path="${output_dir}/cobolcheck${ext}" + output_path="/usr/local/bin/cobolcheck${ext}" download_url="$(get_download_url)" curl "${curlopts[@]}" --output "${output_path}" "${download_url}" chmod +x "${output_path}" diff --git a/exercises/practice/robot-simulator/bin/fetch-cobolcheck.ps1 b/exercises/practice/robot-simulator/bin/fetch-cobolcheck.ps1 index 261f5f45..3e9608d1 100644 --- a/exercises/practice/robot-simulator/bin/fetch-cobolcheck.ps1 +++ b/exercises/practice/robot-simulator/bin/fetch-cobolcheck.ps1 @@ -1,7 +1,6 @@ -# This file is a copy of the -# https://github.com/exercism/configlet/blob/main/scripts/fetch-configlet.ps1 file. -# Please submit bugfixes/improvements to the above file to ensure that all tracks -# benefit from the changes. +# 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" @@ -24,5 +23,7 @@ Function Get-DownloadUrl { } $downloadUrl = Get-DownloadUrl -$outputFile = Join-Path -Path $PSScriptRoot -ChildPath "cobolcheck.exe" -Invoke-WebRequest -Uri $downloadUrl -OutFile $outputFile @requestOpts \ No newline at end of file +$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 diff --git a/exercises/practice/roman-numerals/bin/fetch-cobolcheck b/exercises/practice/roman-numerals/bin/fetch-cobolcheck index dd8159be..16c73077 100755 --- a/exercises/practice/roman-numerals/bin/fetch-cobolcheck +++ b/exercises/practice/roman-numerals/bin/fetch-cobolcheck @@ -45,16 +45,7 @@ get_download_url() { } main() { - if [[ -d ./bin ]]; then - output_dir="./bin" - elif [[ $PWD == */bin ]]; then - output_dir="$PWD" - else - echo "Error: no ./bin directory found. This script should be ran from a repo root." >&2 - return 1 - fi - - output_path="${output_dir}/cobolcheck${ext}" + output_path="/usr/local/bin/cobolcheck${ext}" download_url="$(get_download_url)" curl "${curlopts[@]}" --output "${output_path}" "${download_url}" chmod +x "${output_path}" diff --git a/exercises/practice/roman-numerals/bin/fetch-cobolcheck.ps1 b/exercises/practice/roman-numerals/bin/fetch-cobolcheck.ps1 index a57f708d..3e9608d1 100644 --- a/exercises/practice/roman-numerals/bin/fetch-cobolcheck.ps1 +++ b/exercises/practice/roman-numerals/bin/fetch-cobolcheck.ps1 @@ -23,5 +23,7 @@ Function Get-DownloadUrl { } $downloadUrl = Get-DownloadUrl -$outputFile = Join-Path -Path $PSScriptRoot -ChildPath "cobolcheck.exe" +$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 diff --git a/exercises/practice/rotational-cipher/bin/fetch-cobolcheck b/exercises/practice/rotational-cipher/bin/fetch-cobolcheck index dd8159be..16c73077 100755 --- a/exercises/practice/rotational-cipher/bin/fetch-cobolcheck +++ b/exercises/practice/rotational-cipher/bin/fetch-cobolcheck @@ -45,16 +45,7 @@ get_download_url() { } main() { - if [[ -d ./bin ]]; then - output_dir="./bin" - elif [[ $PWD == */bin ]]; then - output_dir="$PWD" - else - echo "Error: no ./bin directory found. This script should be ran from a repo root." >&2 - return 1 - fi - - output_path="${output_dir}/cobolcheck${ext}" + output_path="/usr/local/bin/cobolcheck${ext}" download_url="$(get_download_url)" curl "${curlopts[@]}" --output "${output_path}" "${download_url}" chmod +x "${output_path}" diff --git a/exercises/practice/rotational-cipher/bin/fetch-cobolcheck.ps1 b/exercises/practice/rotational-cipher/bin/fetch-cobolcheck.ps1 index 65ca602d..3e9608d1 100644 --- a/exercises/practice/rotational-cipher/bin/fetch-cobolcheck.ps1 +++ b/exercises/practice/rotational-cipher/bin/fetch-cobolcheck.ps1 @@ -23,5 +23,7 @@ Function Get-DownloadUrl { } $downloadUrl = Get-DownloadUrl -$outputFile = Join-Path -Path $PSScriptRoot -ChildPath "cobolcheck.exe" -Invoke-WebRequest -Uri $downloadUrl -OutFile $outputFile @requestOpts \ No newline at end of file +$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 diff --git a/exercises/practice/scrabble-score/bin/fetch-cobolcheck b/exercises/practice/scrabble-score/bin/fetch-cobolcheck index 64230fe2..16c73077 100644 --- a/exercises/practice/scrabble-score/bin/fetch-cobolcheck +++ b/exercises/practice/scrabble-score/bin/fetch-cobolcheck @@ -1,10 +1,10 @@ #!/usr/bin/env bash -# This file is a copy of the -# https://github.com/exercism/configlet/blob/main/scripts/fetch-configlet file. -# Please submit bugfixes/improvements to the above file to ensure that all tracks benefit from the changes. +# 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 +set -eo pipefail readonly LATEST='https://api.github.com/repos/0xE282B0/cobol-check/releases/latest' @@ -45,16 +45,7 @@ get_download_url() { } main() { - if [[ -d ./bin ]]; then - output_dir="./bin" - elif [[ $PWD == */bin ]]; then - output_dir="$PWD" - else - echo "Error: no ./bin directory found. This script should be ran from a repo root." >&2 - return 1 - fi - - output_path="${output_dir}/cobolcheck${ext}" + output_path="/usr/local/bin/cobolcheck${ext}" download_url="$(get_download_url)" curl "${curlopts[@]}" --output "${output_path}" "${download_url}" chmod +x "${output_path}" diff --git a/exercises/practice/scrabble-score/bin/fetch-cobolcheck.ps1 b/exercises/practice/scrabble-score/bin/fetch-cobolcheck.ps1 index 261f5f45..3e9608d1 100644 --- a/exercises/practice/scrabble-score/bin/fetch-cobolcheck.ps1 +++ b/exercises/practice/scrabble-score/bin/fetch-cobolcheck.ps1 @@ -1,7 +1,6 @@ -# This file is a copy of the -# https://github.com/exercism/configlet/blob/main/scripts/fetch-configlet.ps1 file. -# Please submit bugfixes/improvements to the above file to ensure that all tracks -# benefit from the changes. +# 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" @@ -24,5 +23,7 @@ Function Get-DownloadUrl { } $downloadUrl = Get-DownloadUrl -$outputFile = Join-Path -Path $PSScriptRoot -ChildPath "cobolcheck.exe" -Invoke-WebRequest -Uri $downloadUrl -OutFile $outputFile @requestOpts \ No newline at end of file +$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 diff --git a/exercises/practice/secret-handshake/bin/fetch-cobolcheck b/exercises/practice/secret-handshake/bin/fetch-cobolcheck index 64230fe2..16c73077 100755 --- a/exercises/practice/secret-handshake/bin/fetch-cobolcheck +++ b/exercises/practice/secret-handshake/bin/fetch-cobolcheck @@ -1,10 +1,10 @@ #!/usr/bin/env bash -# This file is a copy of the -# https://github.com/exercism/configlet/blob/main/scripts/fetch-configlet file. -# Please submit bugfixes/improvements to the above file to ensure that all tracks benefit from the changes. +# 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 +set -eo pipefail readonly LATEST='https://api.github.com/repos/0xE282B0/cobol-check/releases/latest' @@ -45,16 +45,7 @@ get_download_url() { } main() { - if [[ -d ./bin ]]; then - output_dir="./bin" - elif [[ $PWD == */bin ]]; then - output_dir="$PWD" - else - echo "Error: no ./bin directory found. This script should be ran from a repo root." >&2 - return 1 - fi - - output_path="${output_dir}/cobolcheck${ext}" + output_path="/usr/local/bin/cobolcheck${ext}" download_url="$(get_download_url)" curl "${curlopts[@]}" --output "${output_path}" "${download_url}" chmod +x "${output_path}" diff --git a/exercises/practice/secret-handshake/bin/fetch-cobolcheck.ps1 b/exercises/practice/secret-handshake/bin/fetch-cobolcheck.ps1 index 261f5f45..3e9608d1 100644 --- a/exercises/practice/secret-handshake/bin/fetch-cobolcheck.ps1 +++ b/exercises/practice/secret-handshake/bin/fetch-cobolcheck.ps1 @@ -1,7 +1,6 @@ -# This file is a copy of the -# https://github.com/exercism/configlet/blob/main/scripts/fetch-configlet.ps1 file. -# Please submit bugfixes/improvements to the above file to ensure that all tracks -# benefit from the changes. +# 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" @@ -24,5 +23,7 @@ Function Get-DownloadUrl { } $downloadUrl = Get-DownloadUrl -$outputFile = Join-Path -Path $PSScriptRoot -ChildPath "cobolcheck.exe" -Invoke-WebRequest -Uri $downloadUrl -OutFile $outputFile @requestOpts \ No newline at end of file +$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 diff --git a/exercises/practice/sieve/bin/fetch-cobolcheck b/exercises/practice/sieve/bin/fetch-cobolcheck index dd8159be..16c73077 100755 --- a/exercises/practice/sieve/bin/fetch-cobolcheck +++ b/exercises/practice/sieve/bin/fetch-cobolcheck @@ -45,16 +45,7 @@ get_download_url() { } main() { - if [[ -d ./bin ]]; then - output_dir="./bin" - elif [[ $PWD == */bin ]]; then - output_dir="$PWD" - else - echo "Error: no ./bin directory found. This script should be ran from a repo root." >&2 - return 1 - fi - - output_path="${output_dir}/cobolcheck${ext}" + output_path="/usr/local/bin/cobolcheck${ext}" download_url="$(get_download_url)" curl "${curlopts[@]}" --output "${output_path}" "${download_url}" chmod +x "${output_path}" diff --git a/exercises/practice/sieve/bin/fetch-cobolcheck.ps1 b/exercises/practice/sieve/bin/fetch-cobolcheck.ps1 index 65ca602d..3e9608d1 100644 --- a/exercises/practice/sieve/bin/fetch-cobolcheck.ps1 +++ b/exercises/practice/sieve/bin/fetch-cobolcheck.ps1 @@ -23,5 +23,7 @@ Function Get-DownloadUrl { } $downloadUrl = Get-DownloadUrl -$outputFile = Join-Path -Path $PSScriptRoot -ChildPath "cobolcheck.exe" -Invoke-WebRequest -Uri $downloadUrl -OutFile $outputFile @requestOpts \ No newline at end of file +$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 diff --git a/exercises/practice/space-age/bin/fetch-cobolcheck b/exercises/practice/space-age/bin/fetch-cobolcheck index 64230fe2..16c73077 100755 --- a/exercises/practice/space-age/bin/fetch-cobolcheck +++ b/exercises/practice/space-age/bin/fetch-cobolcheck @@ -1,10 +1,10 @@ #!/usr/bin/env bash -# This file is a copy of the -# https://github.com/exercism/configlet/blob/main/scripts/fetch-configlet file. -# Please submit bugfixes/improvements to the above file to ensure that all tracks benefit from the changes. +# 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 +set -eo pipefail readonly LATEST='https://api.github.com/repos/0xE282B0/cobol-check/releases/latest' @@ -45,16 +45,7 @@ get_download_url() { } main() { - if [[ -d ./bin ]]; then - output_dir="./bin" - elif [[ $PWD == */bin ]]; then - output_dir="$PWD" - else - echo "Error: no ./bin directory found. This script should be ran from a repo root." >&2 - return 1 - fi - - output_path="${output_dir}/cobolcheck${ext}" + output_path="/usr/local/bin/cobolcheck${ext}" download_url="$(get_download_url)" curl "${curlopts[@]}" --output "${output_path}" "${download_url}" chmod +x "${output_path}" diff --git a/exercises/practice/space-age/bin/fetch-cobolcheck.ps1 b/exercises/practice/space-age/bin/fetch-cobolcheck.ps1 index 261f5f45..3e9608d1 100644 --- a/exercises/practice/space-age/bin/fetch-cobolcheck.ps1 +++ b/exercises/practice/space-age/bin/fetch-cobolcheck.ps1 @@ -1,7 +1,6 @@ -# This file is a copy of the -# https://github.com/exercism/configlet/blob/main/scripts/fetch-configlet.ps1 file. -# Please submit bugfixes/improvements to the above file to ensure that all tracks -# benefit from the changes. +# 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" @@ -24,5 +23,7 @@ Function Get-DownloadUrl { } $downloadUrl = Get-DownloadUrl -$outputFile = Join-Path -Path $PSScriptRoot -ChildPath "cobolcheck.exe" -Invoke-WebRequest -Uri $downloadUrl -OutFile $outputFile @requestOpts \ No newline at end of file +$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 diff --git a/exercises/practice/square-root/bin/fetch-cobolcheck b/exercises/practice/square-root/bin/fetch-cobolcheck index dd8159be..16c73077 100755 --- a/exercises/practice/square-root/bin/fetch-cobolcheck +++ b/exercises/practice/square-root/bin/fetch-cobolcheck @@ -45,16 +45,7 @@ get_download_url() { } main() { - if [[ -d ./bin ]]; then - output_dir="./bin" - elif [[ $PWD == */bin ]]; then - output_dir="$PWD" - else - echo "Error: no ./bin directory found. This script should be ran from a repo root." >&2 - return 1 - fi - - output_path="${output_dir}/cobolcheck${ext}" + output_path="/usr/local/bin/cobolcheck${ext}" download_url="$(get_download_url)" curl "${curlopts[@]}" --output "${output_path}" "${download_url}" chmod +x "${output_path}" diff --git a/exercises/practice/square-root/bin/fetch-cobolcheck.ps1 b/exercises/practice/square-root/bin/fetch-cobolcheck.ps1 index 65ca602d..3e9608d1 100644 --- a/exercises/practice/square-root/bin/fetch-cobolcheck.ps1 +++ b/exercises/practice/square-root/bin/fetch-cobolcheck.ps1 @@ -23,5 +23,7 @@ Function Get-DownloadUrl { } $downloadUrl = Get-DownloadUrl -$outputFile = Join-Path -Path $PSScriptRoot -ChildPath "cobolcheck.exe" -Invoke-WebRequest -Uri $downloadUrl -OutFile $outputFile @requestOpts \ No newline at end of file +$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 diff --git a/exercises/practice/triangle/bin/fetch-cobolcheck b/exercises/practice/triangle/bin/fetch-cobolcheck index 64230fe2..16c73077 100644 --- a/exercises/practice/triangle/bin/fetch-cobolcheck +++ b/exercises/practice/triangle/bin/fetch-cobolcheck @@ -1,10 +1,10 @@ #!/usr/bin/env bash -# This file is a copy of the -# https://github.com/exercism/configlet/blob/main/scripts/fetch-configlet file. -# Please submit bugfixes/improvements to the above file to ensure that all tracks benefit from the changes. +# 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 +set -eo pipefail readonly LATEST='https://api.github.com/repos/0xE282B0/cobol-check/releases/latest' @@ -45,16 +45,7 @@ get_download_url() { } main() { - if [[ -d ./bin ]]; then - output_dir="./bin" - elif [[ $PWD == */bin ]]; then - output_dir="$PWD" - else - echo "Error: no ./bin directory found. This script should be ran from a repo root." >&2 - return 1 - fi - - output_path="${output_dir}/cobolcheck${ext}" + output_path="/usr/local/bin/cobolcheck${ext}" download_url="$(get_download_url)" curl "${curlopts[@]}" --output "${output_path}" "${download_url}" chmod +x "${output_path}" diff --git a/exercises/practice/triangle/bin/fetch-cobolcheck.ps1 b/exercises/practice/triangle/bin/fetch-cobolcheck.ps1 index 1535c6e8..3e9608d1 100644 --- a/exercises/practice/triangle/bin/fetch-cobolcheck.ps1 +++ b/exercises/practice/triangle/bin/fetch-cobolcheck.ps1 @@ -1,7 +1,6 @@ -# This file is a copy of the -# https://github.com/exercism/configlet/blob/main/scripts/fetch-configlet.ps1 file. -# Please submit bugfixes/improvements to the above file to ensure that all tracks -# benefit from the changes. +# 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" @@ -24,5 +23,7 @@ Function Get-DownloadUrl { } $downloadUrl = Get-DownloadUrl -$outputFile = Join-Path -Path $PSScriptRoot -ChildPath "cobolcheck.exe" +$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 diff --git a/exercises/practice/two-fer/bin/fetch-cobolcheck b/exercises/practice/two-fer/bin/fetch-cobolcheck index dd8159be..16c73077 100755 --- a/exercises/practice/two-fer/bin/fetch-cobolcheck +++ b/exercises/practice/two-fer/bin/fetch-cobolcheck @@ -45,16 +45,7 @@ get_download_url() { } main() { - if [[ -d ./bin ]]; then - output_dir="./bin" - elif [[ $PWD == */bin ]]; then - output_dir="$PWD" - else - echo "Error: no ./bin directory found. This script should be ran from a repo root." >&2 - return 1 - fi - - output_path="${output_dir}/cobolcheck${ext}" + output_path="/usr/local/bin/cobolcheck${ext}" download_url="$(get_download_url)" curl "${curlopts[@]}" --output "${output_path}" "${download_url}" chmod +x "${output_path}" diff --git a/exercises/practice/two-fer/bin/fetch-cobolcheck.ps1 b/exercises/practice/two-fer/bin/fetch-cobolcheck.ps1 index 65ca602d..3e9608d1 100644 --- a/exercises/practice/two-fer/bin/fetch-cobolcheck.ps1 +++ b/exercises/practice/two-fer/bin/fetch-cobolcheck.ps1 @@ -23,5 +23,7 @@ Function Get-DownloadUrl { } $downloadUrl = Get-DownloadUrl -$outputFile = Join-Path -Path $PSScriptRoot -ChildPath "cobolcheck.exe" -Invoke-WebRequest -Uri $downloadUrl -OutFile $outputFile @requestOpts \ No newline at end of file +$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 diff --git a/exercises/practice/yacht/bin/fetch-cobolcheck b/exercises/practice/yacht/bin/fetch-cobolcheck index dd8159be..16c73077 100755 --- a/exercises/practice/yacht/bin/fetch-cobolcheck +++ b/exercises/practice/yacht/bin/fetch-cobolcheck @@ -45,16 +45,7 @@ get_download_url() { } main() { - if [[ -d ./bin ]]; then - output_dir="./bin" - elif [[ $PWD == */bin ]]; then - output_dir="$PWD" - else - echo "Error: no ./bin directory found. This script should be ran from a repo root." >&2 - return 1 - fi - - output_path="${output_dir}/cobolcheck${ext}" + output_path="/usr/local/bin/cobolcheck${ext}" download_url="$(get_download_url)" curl "${curlopts[@]}" --output "${output_path}" "${download_url}" chmod +x "${output_path}" diff --git a/exercises/practice/yacht/bin/fetch-cobolcheck.ps1 b/exercises/practice/yacht/bin/fetch-cobolcheck.ps1 index 65ca602d..3e9608d1 100644 --- a/exercises/practice/yacht/bin/fetch-cobolcheck.ps1 +++ b/exercises/practice/yacht/bin/fetch-cobolcheck.ps1 @@ -23,5 +23,7 @@ Function Get-DownloadUrl { } $downloadUrl = Get-DownloadUrl -$outputFile = Join-Path -Path $PSScriptRoot -ChildPath "cobolcheck.exe" -Invoke-WebRequest -Uri $downloadUrl -OutFile $outputFile @requestOpts \ No newline at end of file +$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