From b3583d71d672e49175ed76d8fd2da35e6d11340d Mon Sep 17 00:00:00 2001 From: SimaDovakin Date: Tue, 6 Aug 2024 16:50:24 +0300 Subject: [PATCH 1/4] Reverted fetch-cobolcheck and fetch-cobolcheck.ps1 scripts. --- bin/fetch-cobolcheck | 13 +++++++++++-- bin/fetch-cobolcheck.ps1 | 4 +--- exercises/practice/acronym/bin/fetch-cobolcheck | 13 +++++++++++-- exercises/practice/acronym/bin/fetch-cobolcheck.ps1 | 4 +--- .../practice/all-your-base/bin/fetch-cobolcheck | 13 +++++++++++-- .../practice/all-your-base/bin/fetch-cobolcheck.ps1 | 4 +--- exercises/practice/allergies/bin/fetch-cobolcheck | 13 +++++++++++-- .../practice/allergies/bin/fetch-cobolcheck.ps1 | 4 +--- exercises/practice/anagram/bin/fetch-cobolcheck | 13 +++++++++++-- exercises/practice/anagram/bin/fetch-cobolcheck.ps1 | 4 +--- .../practice/armstrong-numbers/bin/fetch-cobolcheck | 13 +++++++++++-- .../armstrong-numbers/bin/fetch-cobolcheck.ps1 | 4 +--- .../practice/atbash-cipher/bin/fetch-cobolcheck | 13 +++++++++++-- .../practice/atbash-cipher/bin/fetch-cobolcheck.ps1 | 4 +--- .../practice/binary-search/bin/fetch-cobolcheck | 13 +++++++++++-- .../practice/binary-search/bin/fetch-cobolcheck.ps1 | 4 +--- exercises/practice/binary/bin/fetch-cobolcheck | 13 +++++++++++-- exercises/practice/binary/bin/fetch-cobolcheck.ps1 | 4 +--- exercises/practice/bob/bin/fetch-cobolcheck | 13 +++++++++++-- exercises/practice/bob/bin/fetch-cobolcheck.ps1 | 4 +--- .../practice/circular-buffer/bin/fetch-cobolcheck | 13 +++++++++++-- .../circular-buffer/bin/fetch-cobolcheck.ps1 | 4 +--- .../collatz-conjecture/bin/fetch-cobolcheck | 13 +++++++++++-- .../collatz-conjecture/bin/fetch-cobolcheck.ps1 | 4 +--- .../practice/complex-numbers/bin/fetch-cobolcheck | 13 +++++++++++-- .../complex-numbers/bin/fetch-cobolcheck.ps1 | 4 +--- exercises/practice/darts/bin/fetch-cobolcheck | 13 +++++++++++-- exercises/practice/darts/bin/fetch-cobolcheck.ps1 | 4 +--- exercises/practice/diamond/bin/fetch-cobolcheck | 13 +++++++++++-- exercises/practice/diamond/bin/fetch-cobolcheck.ps1 | 4 +--- .../difference-of-squares/bin/fetch-cobolcheck | 13 +++++++++++-- .../difference-of-squares/bin/fetch-cobolcheck.ps1 | 4 +--- exercises/practice/eliuds-eggs/bin/fetch-cobolcheck | 13 +++++++++++-- .../practice/eliuds-eggs/bin/fetch-cobolcheck.ps1 | 4 +--- .../practice/grade-school/bin/fetch-cobolcheck | 13 +++++++++++-- .../practice/grade-school/bin/fetch-cobolcheck.ps1 | 4 +--- exercises/practice/hamming/bin/fetch-cobolcheck | 13 +++++++++++-- exercises/practice/hamming/bin/fetch-cobolcheck.ps1 | 4 +--- exercises/practice/hello-world/bin/fetch-cobolcheck | 13 +++++++++++-- .../practice/hello-world/bin/fetch-cobolcheck.ps1 | 4 +--- exercises/practice/high-scores/bin/fetch-cobolcheck | 13 +++++++++++-- .../practice/high-scores/bin/fetch-cobolcheck.ps1 | 4 +--- exercises/practice/isogram/bin/fetch-cobolcheck | 13 +++++++++++-- exercises/practice/isogram/bin/fetch-cobolcheck.ps1 | 4 +--- exercises/practice/knapsack/bin/fetch-cobolcheck | 13 +++++++++++-- .../practice/knapsack/bin/fetch-cobolcheck.ps1 | 4 +--- exercises/practice/leap/bin/fetch-cobolcheck | 13 +++++++++++-- exercises/practice/leap/bin/fetch-cobolcheck.ps1 | 4 +--- exercises/practice/luhn/bin/fetch-cobolcheck | 13 +++++++++++-- exercises/practice/luhn/bin/fetch-cobolcheck.ps1 | 4 +--- .../practice/matching-brackets/bin/fetch-cobolcheck | 13 +++++++++++-- .../matching-brackets/bin/fetch-cobolcheck.ps1 | 4 +--- exercises/practice/meetup/bin/fetch-cobolcheck | 13 +++++++++++-- exercises/practice/meetup/bin/fetch-cobolcheck.ps1 | 4 +--- .../practice/nucleotide-count/bin/fetch-cobolcheck | 13 +++++++++++-- .../nucleotide-count/bin/fetch-cobolcheck.ps1 | 4 +--- exercises/practice/pangram/bin/fetch-cobolcheck | 13 +++++++++++-- exercises/practice/pangram/bin/fetch-cobolcheck.ps1 | 4 +--- .../practice/pascals-triangle/bin/fetch-cobolcheck | 13 +++++++++++-- .../pascals-triangle/bin/fetch-cobolcheck.ps1 | 4 +--- exercises/practice/pig-latin/bin/fetch-cobolcheck | 13 +++++++++++-- .../practice/pig-latin/bin/fetch-cobolcheck.ps1 | 4 +--- .../protein-translation/bin/fetch-cobolcheck | 13 +++++++++++-- .../protein-translation/bin/fetch-cobolcheck.ps1 | 4 +--- .../practice/queen-attack/bin/fetch-cobolcheck | 13 +++++++++++-- .../practice/queen-attack/bin/fetch-cobolcheck.ps1 | 4 +--- exercises/practice/raindrops/bin/fetch-cobolcheck | 13 +++++++++++-- .../practice/raindrops/bin/fetch-cobolcheck.ps1 | 4 +--- .../practice/reverse-string/bin/fetch-cobolcheck | 13 +++++++++++-- .../reverse-string/bin/fetch-cobolcheck.ps1 | 4 +--- .../practice/rna-transcription/bin/fetch-cobolcheck | 13 +++++++++++-- .../rna-transcription/bin/fetch-cobolcheck.ps1 | 4 +--- .../practice/robot-simulator/bin/fetch-cobolcheck | 13 +++++++++++-- .../robot-simulator/bin/fetch-cobolcheck.ps1 | 4 +--- .../practice/roman-numerals/bin/fetch-cobolcheck | 13 +++++++++++-- .../roman-numerals/bin/fetch-cobolcheck.ps1 | 4 +--- .../practice/rotational-cipher/bin/fetch-cobolcheck | 13 +++++++++++-- .../rotational-cipher/bin/fetch-cobolcheck.ps1 | 4 +--- .../practice/scrabble-score/bin/fetch-cobolcheck | 13 +++++++++++-- .../scrabble-score/bin/fetch-cobolcheck.ps1 | 4 +--- .../practice/secret-handshake/bin/fetch-cobolcheck | 13 +++++++++++-- .../secret-handshake/bin/fetch-cobolcheck.ps1 | 4 +--- exercises/practice/sieve/bin/fetch-cobolcheck | 13 +++++++++++-- exercises/practice/sieve/bin/fetch-cobolcheck.ps1 | 4 +--- exercises/practice/space-age/bin/fetch-cobolcheck | 13 +++++++++++-- .../practice/space-age/bin/fetch-cobolcheck.ps1 | 4 +--- exercises/practice/square-root/bin/fetch-cobolcheck | 13 +++++++++++-- .../practice/square-root/bin/fetch-cobolcheck.ps1 | 4 +--- exercises/practice/triangle/bin/fetch-cobolcheck | 13 +++++++++++-- .../practice/triangle/bin/fetch-cobolcheck.ps1 | 4 +--- exercises/practice/two-fer/bin/fetch-cobolcheck | 13 +++++++++++-- exercises/practice/two-fer/bin/fetch-cobolcheck.ps1 | 4 +--- exercises/practice/yacht/bin/fetch-cobolcheck | 13 +++++++++++-- exercises/practice/yacht/bin/fetch-cobolcheck.ps1 | 4 +--- 94 files changed, 564 insertions(+), 235 deletions(-) diff --git a/bin/fetch-cobolcheck b/bin/fetch-cobolcheck index 16c73077..0b668734 100755 --- a/bin/fetch-cobolcheck +++ b/bin/fetch-cobolcheck @@ -4,7 +4,7 @@ # 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,7 +45,16 @@ get_download_url() { } main() { - output_path="/usr/local/bin/cobolcheck${ext}" + 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}" download_url="$(get_download_url)" curl "${curlopts[@]}" --output "${output_path}" "${download_url}" chmod +x "${output_path}" diff --git a/bin/fetch-cobolcheck.ps1 b/bin/fetch-cobolcheck.ps1 index 3e9608d1..a57f708d 100644 --- a/bin/fetch-cobolcheck.ps1 +++ b/bin/fetch-cobolcheck.ps1 @@ -23,7 +23,5 @@ Function Get-DownloadUrl { } $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 +$outputFile = Join-Path -Path $PSScriptRoot -ChildPath "cobolcheck.exe" Invoke-WebRequest -Uri $downloadUrl -OutFile $outputFile @requestOpts diff --git a/exercises/practice/acronym/bin/fetch-cobolcheck b/exercises/practice/acronym/bin/fetch-cobolcheck index 16c73077..0b668734 100755 --- a/exercises/practice/acronym/bin/fetch-cobolcheck +++ b/exercises/practice/acronym/bin/fetch-cobolcheck @@ -4,7 +4,7 @@ # 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,7 +45,16 @@ get_download_url() { } main() { - output_path="/usr/local/bin/cobolcheck${ext}" + 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}" 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 3e9608d1..a57f708d 100644 --- a/exercises/practice/acronym/bin/fetch-cobolcheck.ps1 +++ b/exercises/practice/acronym/bin/fetch-cobolcheck.ps1 @@ -23,7 +23,5 @@ Function Get-DownloadUrl { } $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 +$outputFile = Join-Path -Path $PSScriptRoot -ChildPath "cobolcheck.exe" 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 16c73077..0b668734 100755 --- a/exercises/practice/all-your-base/bin/fetch-cobolcheck +++ b/exercises/practice/all-your-base/bin/fetch-cobolcheck @@ -4,7 +4,7 @@ # 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,7 +45,16 @@ get_download_url() { } main() { - output_path="/usr/local/bin/cobolcheck${ext}" + 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}" 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 3e9608d1..a57f708d 100644 --- a/exercises/practice/all-your-base/bin/fetch-cobolcheck.ps1 +++ b/exercises/practice/all-your-base/bin/fetch-cobolcheck.ps1 @@ -23,7 +23,5 @@ Function Get-DownloadUrl { } $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 +$outputFile = Join-Path -Path $PSScriptRoot -ChildPath "cobolcheck.exe" Invoke-WebRequest -Uri $downloadUrl -OutFile $outputFile @requestOpts diff --git a/exercises/practice/allergies/bin/fetch-cobolcheck b/exercises/practice/allergies/bin/fetch-cobolcheck index 16c73077..0b668734 100755 --- a/exercises/practice/allergies/bin/fetch-cobolcheck +++ b/exercises/practice/allergies/bin/fetch-cobolcheck @@ -4,7 +4,7 @@ # 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,7 +45,16 @@ get_download_url() { } main() { - output_path="/usr/local/bin/cobolcheck${ext}" + 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}" 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 3e9608d1..a57f708d 100644 --- a/exercises/practice/allergies/bin/fetch-cobolcheck.ps1 +++ b/exercises/practice/allergies/bin/fetch-cobolcheck.ps1 @@ -23,7 +23,5 @@ Function Get-DownloadUrl { } $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 +$outputFile = Join-Path -Path $PSScriptRoot -ChildPath "cobolcheck.exe" Invoke-WebRequest -Uri $downloadUrl -OutFile $outputFile @requestOpts diff --git a/exercises/practice/anagram/bin/fetch-cobolcheck b/exercises/practice/anagram/bin/fetch-cobolcheck index 16c73077..0b668734 100755 --- a/exercises/practice/anagram/bin/fetch-cobolcheck +++ b/exercises/practice/anagram/bin/fetch-cobolcheck @@ -4,7 +4,7 @@ # 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,7 +45,16 @@ get_download_url() { } main() { - output_path="/usr/local/bin/cobolcheck${ext}" + 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}" download_url="$(get_download_url)" curl "${curlopts[@]}" --output "${output_path}" "${download_url}" chmod +x "${output_path}" diff --git a/exercises/practice/anagram/bin/fetch-cobolcheck.ps1 b/exercises/practice/anagram/bin/fetch-cobolcheck.ps1 index 3e9608d1..a57f708d 100644 --- a/exercises/practice/anagram/bin/fetch-cobolcheck.ps1 +++ b/exercises/practice/anagram/bin/fetch-cobolcheck.ps1 @@ -23,7 +23,5 @@ Function Get-DownloadUrl { } $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 +$outputFile = Join-Path -Path $PSScriptRoot -ChildPath "cobolcheck.exe" 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 16c73077..0b668734 100755 --- a/exercises/practice/armstrong-numbers/bin/fetch-cobolcheck +++ b/exercises/practice/armstrong-numbers/bin/fetch-cobolcheck @@ -4,7 +4,7 @@ # 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,7 +45,16 @@ get_download_url() { } main() { - output_path="/usr/local/bin/cobolcheck${ext}" + 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}" 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 3e9608d1..a57f708d 100644 --- a/exercises/practice/armstrong-numbers/bin/fetch-cobolcheck.ps1 +++ b/exercises/practice/armstrong-numbers/bin/fetch-cobolcheck.ps1 @@ -23,7 +23,5 @@ Function Get-DownloadUrl { } $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 +$outputFile = Join-Path -Path $PSScriptRoot -ChildPath "cobolcheck.exe" 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 16c73077..0b668734 100755 --- a/exercises/practice/atbash-cipher/bin/fetch-cobolcheck +++ b/exercises/practice/atbash-cipher/bin/fetch-cobolcheck @@ -4,7 +4,7 @@ # 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,7 +45,16 @@ get_download_url() { } main() { - output_path="/usr/local/bin/cobolcheck${ext}" + 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}" 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 3e9608d1..a57f708d 100644 --- a/exercises/practice/atbash-cipher/bin/fetch-cobolcheck.ps1 +++ b/exercises/practice/atbash-cipher/bin/fetch-cobolcheck.ps1 @@ -23,7 +23,5 @@ Function Get-DownloadUrl { } $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 +$outputFile = Join-Path -Path $PSScriptRoot -ChildPath "cobolcheck.exe" 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 16c73077..0b668734 100755 --- a/exercises/practice/binary-search/bin/fetch-cobolcheck +++ b/exercises/practice/binary-search/bin/fetch-cobolcheck @@ -4,7 +4,7 @@ # 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,7 +45,16 @@ get_download_url() { } main() { - output_path="/usr/local/bin/cobolcheck${ext}" + 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}" 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 3e9608d1..a57f708d 100644 --- a/exercises/practice/binary-search/bin/fetch-cobolcheck.ps1 +++ b/exercises/practice/binary-search/bin/fetch-cobolcheck.ps1 @@ -23,7 +23,5 @@ Function Get-DownloadUrl { } $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 +$outputFile = Join-Path -Path $PSScriptRoot -ChildPath "cobolcheck.exe" Invoke-WebRequest -Uri $downloadUrl -OutFile $outputFile @requestOpts diff --git a/exercises/practice/binary/bin/fetch-cobolcheck b/exercises/practice/binary/bin/fetch-cobolcheck index 16c73077..0b668734 100755 --- a/exercises/practice/binary/bin/fetch-cobolcheck +++ b/exercises/practice/binary/bin/fetch-cobolcheck @@ -4,7 +4,7 @@ # 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,7 +45,16 @@ get_download_url() { } main() { - output_path="/usr/local/bin/cobolcheck${ext}" + 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}" 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 3e9608d1..a57f708d 100644 --- a/exercises/practice/binary/bin/fetch-cobolcheck.ps1 +++ b/exercises/practice/binary/bin/fetch-cobolcheck.ps1 @@ -23,7 +23,5 @@ Function Get-DownloadUrl { } $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 +$outputFile = Join-Path -Path $PSScriptRoot -ChildPath "cobolcheck.exe" Invoke-WebRequest -Uri $downloadUrl -OutFile $outputFile @requestOpts diff --git a/exercises/practice/bob/bin/fetch-cobolcheck b/exercises/practice/bob/bin/fetch-cobolcheck index 16c73077..0b668734 100755 --- a/exercises/practice/bob/bin/fetch-cobolcheck +++ b/exercises/practice/bob/bin/fetch-cobolcheck @@ -4,7 +4,7 @@ # 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,7 +45,16 @@ get_download_url() { } main() { - output_path="/usr/local/bin/cobolcheck${ext}" + 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}" 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 3e9608d1..a57f708d 100644 --- a/exercises/practice/bob/bin/fetch-cobolcheck.ps1 +++ b/exercises/practice/bob/bin/fetch-cobolcheck.ps1 @@ -23,7 +23,5 @@ Function Get-DownloadUrl { } $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 +$outputFile = Join-Path -Path $PSScriptRoot -ChildPath "cobolcheck.exe" 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 16c73077..0b668734 100755 --- a/exercises/practice/circular-buffer/bin/fetch-cobolcheck +++ b/exercises/practice/circular-buffer/bin/fetch-cobolcheck @@ -4,7 +4,7 @@ # 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,7 +45,16 @@ get_download_url() { } main() { - output_path="/usr/local/bin/cobolcheck${ext}" + 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}" 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 3e9608d1..a57f708d 100644 --- a/exercises/practice/circular-buffer/bin/fetch-cobolcheck.ps1 +++ b/exercises/practice/circular-buffer/bin/fetch-cobolcheck.ps1 @@ -23,7 +23,5 @@ Function Get-DownloadUrl { } $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 +$outputFile = Join-Path -Path $PSScriptRoot -ChildPath "cobolcheck.exe" 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 16c73077..0b668734 100755 --- a/exercises/practice/collatz-conjecture/bin/fetch-cobolcheck +++ b/exercises/practice/collatz-conjecture/bin/fetch-cobolcheck @@ -4,7 +4,7 @@ # 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,7 +45,16 @@ get_download_url() { } main() { - output_path="/usr/local/bin/cobolcheck${ext}" + 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}" 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 3e9608d1..a57f708d 100644 --- a/exercises/practice/collatz-conjecture/bin/fetch-cobolcheck.ps1 +++ b/exercises/practice/collatz-conjecture/bin/fetch-cobolcheck.ps1 @@ -23,7 +23,5 @@ Function Get-DownloadUrl { } $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 +$outputFile = Join-Path -Path $PSScriptRoot -ChildPath "cobolcheck.exe" 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 16c73077..0b668734 100755 --- a/exercises/practice/complex-numbers/bin/fetch-cobolcheck +++ b/exercises/practice/complex-numbers/bin/fetch-cobolcheck @@ -4,7 +4,7 @@ # 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,7 +45,16 @@ get_download_url() { } main() { - output_path="/usr/local/bin/cobolcheck${ext}" + 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}" 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 3e9608d1..a57f708d 100644 --- a/exercises/practice/complex-numbers/bin/fetch-cobolcheck.ps1 +++ b/exercises/practice/complex-numbers/bin/fetch-cobolcheck.ps1 @@ -23,7 +23,5 @@ Function Get-DownloadUrl { } $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 +$outputFile = Join-Path -Path $PSScriptRoot -ChildPath "cobolcheck.exe" Invoke-WebRequest -Uri $downloadUrl -OutFile $outputFile @requestOpts diff --git a/exercises/practice/darts/bin/fetch-cobolcheck b/exercises/practice/darts/bin/fetch-cobolcheck index 16c73077..0b668734 100755 --- a/exercises/practice/darts/bin/fetch-cobolcheck +++ b/exercises/practice/darts/bin/fetch-cobolcheck @@ -4,7 +4,7 @@ # 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,7 +45,16 @@ get_download_url() { } main() { - output_path="/usr/local/bin/cobolcheck${ext}" + 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}" 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 3e9608d1..a57f708d 100644 --- a/exercises/practice/darts/bin/fetch-cobolcheck.ps1 +++ b/exercises/practice/darts/bin/fetch-cobolcheck.ps1 @@ -23,7 +23,5 @@ Function Get-DownloadUrl { } $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 +$outputFile = Join-Path -Path $PSScriptRoot -ChildPath "cobolcheck.exe" Invoke-WebRequest -Uri $downloadUrl -OutFile $outputFile @requestOpts diff --git a/exercises/practice/diamond/bin/fetch-cobolcheck b/exercises/practice/diamond/bin/fetch-cobolcheck index 16c73077..0b668734 100755 --- a/exercises/practice/diamond/bin/fetch-cobolcheck +++ b/exercises/practice/diamond/bin/fetch-cobolcheck @@ -4,7 +4,7 @@ # 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,7 +45,16 @@ get_download_url() { } main() { - output_path="/usr/local/bin/cobolcheck${ext}" + 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}" 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 3e9608d1..a57f708d 100644 --- a/exercises/practice/diamond/bin/fetch-cobolcheck.ps1 +++ b/exercises/practice/diamond/bin/fetch-cobolcheck.ps1 @@ -23,7 +23,5 @@ Function Get-DownloadUrl { } $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 +$outputFile = Join-Path -Path $PSScriptRoot -ChildPath "cobolcheck.exe" 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 16c73077..0b668734 100755 --- a/exercises/practice/difference-of-squares/bin/fetch-cobolcheck +++ b/exercises/practice/difference-of-squares/bin/fetch-cobolcheck @@ -4,7 +4,7 @@ # 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,7 +45,16 @@ get_download_url() { } main() { - output_path="/usr/local/bin/cobolcheck${ext}" + 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}" 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 3e9608d1..a57f708d 100644 --- a/exercises/practice/difference-of-squares/bin/fetch-cobolcheck.ps1 +++ b/exercises/practice/difference-of-squares/bin/fetch-cobolcheck.ps1 @@ -23,7 +23,5 @@ Function Get-DownloadUrl { } $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 +$outputFile = Join-Path -Path $PSScriptRoot -ChildPath "cobolcheck.exe" 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 16c73077..0b668734 100755 --- a/exercises/practice/eliuds-eggs/bin/fetch-cobolcheck +++ b/exercises/practice/eliuds-eggs/bin/fetch-cobolcheck @@ -4,7 +4,7 @@ # 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,7 +45,16 @@ get_download_url() { } main() { - output_path="/usr/local/bin/cobolcheck${ext}" + 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}" 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 3e9608d1..a57f708d 100644 --- a/exercises/practice/eliuds-eggs/bin/fetch-cobolcheck.ps1 +++ b/exercises/practice/eliuds-eggs/bin/fetch-cobolcheck.ps1 @@ -23,7 +23,5 @@ Function Get-DownloadUrl { } $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 +$outputFile = Join-Path -Path $PSScriptRoot -ChildPath "cobolcheck.exe" 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 16c73077..0b668734 100755 --- a/exercises/practice/grade-school/bin/fetch-cobolcheck +++ b/exercises/practice/grade-school/bin/fetch-cobolcheck @@ -4,7 +4,7 @@ # 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,7 +45,16 @@ get_download_url() { } main() { - output_path="/usr/local/bin/cobolcheck${ext}" + 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}" 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 3e9608d1..a57f708d 100644 --- a/exercises/practice/grade-school/bin/fetch-cobolcheck.ps1 +++ b/exercises/practice/grade-school/bin/fetch-cobolcheck.ps1 @@ -23,7 +23,5 @@ Function Get-DownloadUrl { } $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 +$outputFile = Join-Path -Path $PSScriptRoot -ChildPath "cobolcheck.exe" Invoke-WebRequest -Uri $downloadUrl -OutFile $outputFile @requestOpts diff --git a/exercises/practice/hamming/bin/fetch-cobolcheck b/exercises/practice/hamming/bin/fetch-cobolcheck index 16c73077..0b668734 100755 --- a/exercises/practice/hamming/bin/fetch-cobolcheck +++ b/exercises/practice/hamming/bin/fetch-cobolcheck @@ -4,7 +4,7 @@ # 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,7 +45,16 @@ get_download_url() { } main() { - output_path="/usr/local/bin/cobolcheck${ext}" + 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}" 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 3e9608d1..a57f708d 100644 --- a/exercises/practice/hamming/bin/fetch-cobolcheck.ps1 +++ b/exercises/practice/hamming/bin/fetch-cobolcheck.ps1 @@ -23,7 +23,5 @@ Function Get-DownloadUrl { } $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 +$outputFile = Join-Path -Path $PSScriptRoot -ChildPath "cobolcheck.exe" 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 16c73077..0b668734 100755 --- a/exercises/practice/hello-world/bin/fetch-cobolcheck +++ b/exercises/practice/hello-world/bin/fetch-cobolcheck @@ -4,7 +4,7 @@ # 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,7 +45,16 @@ get_download_url() { } main() { - output_path="/usr/local/bin/cobolcheck${ext}" + 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}" 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 3e9608d1..a57f708d 100644 --- a/exercises/practice/hello-world/bin/fetch-cobolcheck.ps1 +++ b/exercises/practice/hello-world/bin/fetch-cobolcheck.ps1 @@ -23,7 +23,5 @@ Function Get-DownloadUrl { } $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 +$outputFile = Join-Path -Path $PSScriptRoot -ChildPath "cobolcheck.exe" 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 16c73077..0b668734 100755 --- a/exercises/practice/high-scores/bin/fetch-cobolcheck +++ b/exercises/practice/high-scores/bin/fetch-cobolcheck @@ -4,7 +4,7 @@ # 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,7 +45,16 @@ get_download_url() { } main() { - output_path="/usr/local/bin/cobolcheck${ext}" + 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}" 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 3e9608d1..a57f708d 100644 --- a/exercises/practice/high-scores/bin/fetch-cobolcheck.ps1 +++ b/exercises/practice/high-scores/bin/fetch-cobolcheck.ps1 @@ -23,7 +23,5 @@ Function Get-DownloadUrl { } $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 +$outputFile = Join-Path -Path $PSScriptRoot -ChildPath "cobolcheck.exe" Invoke-WebRequest -Uri $downloadUrl -OutFile $outputFile @requestOpts diff --git a/exercises/practice/isogram/bin/fetch-cobolcheck b/exercises/practice/isogram/bin/fetch-cobolcheck index 16c73077..0b668734 100755 --- a/exercises/practice/isogram/bin/fetch-cobolcheck +++ b/exercises/practice/isogram/bin/fetch-cobolcheck @@ -4,7 +4,7 @@ # 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,7 +45,16 @@ get_download_url() { } main() { - output_path="/usr/local/bin/cobolcheck${ext}" + 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}" 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 3e9608d1..a57f708d 100644 --- a/exercises/practice/isogram/bin/fetch-cobolcheck.ps1 +++ b/exercises/practice/isogram/bin/fetch-cobolcheck.ps1 @@ -23,7 +23,5 @@ Function Get-DownloadUrl { } $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 +$outputFile = Join-Path -Path $PSScriptRoot -ChildPath "cobolcheck.exe" Invoke-WebRequest -Uri $downloadUrl -OutFile $outputFile @requestOpts diff --git a/exercises/practice/knapsack/bin/fetch-cobolcheck b/exercises/practice/knapsack/bin/fetch-cobolcheck index 16c73077..0b668734 100755 --- a/exercises/practice/knapsack/bin/fetch-cobolcheck +++ b/exercises/practice/knapsack/bin/fetch-cobolcheck @@ -4,7 +4,7 @@ # 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,7 +45,16 @@ get_download_url() { } main() { - output_path="/usr/local/bin/cobolcheck${ext}" + 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}" 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 3e9608d1..a57f708d 100644 --- a/exercises/practice/knapsack/bin/fetch-cobolcheck.ps1 +++ b/exercises/practice/knapsack/bin/fetch-cobolcheck.ps1 @@ -23,7 +23,5 @@ Function Get-DownloadUrl { } $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 +$outputFile = Join-Path -Path $PSScriptRoot -ChildPath "cobolcheck.exe" Invoke-WebRequest -Uri $downloadUrl -OutFile $outputFile @requestOpts diff --git a/exercises/practice/leap/bin/fetch-cobolcheck b/exercises/practice/leap/bin/fetch-cobolcheck index 16c73077..0b668734 100755 --- a/exercises/practice/leap/bin/fetch-cobolcheck +++ b/exercises/practice/leap/bin/fetch-cobolcheck @@ -4,7 +4,7 @@ # 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,7 +45,16 @@ get_download_url() { } main() { - output_path="/usr/local/bin/cobolcheck${ext}" + 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}" 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 3e9608d1..a57f708d 100644 --- a/exercises/practice/leap/bin/fetch-cobolcheck.ps1 +++ b/exercises/practice/leap/bin/fetch-cobolcheck.ps1 @@ -23,7 +23,5 @@ Function Get-DownloadUrl { } $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 +$outputFile = Join-Path -Path $PSScriptRoot -ChildPath "cobolcheck.exe" Invoke-WebRequest -Uri $downloadUrl -OutFile $outputFile @requestOpts diff --git a/exercises/practice/luhn/bin/fetch-cobolcheck b/exercises/practice/luhn/bin/fetch-cobolcheck index 16c73077..0b668734 100755 --- a/exercises/practice/luhn/bin/fetch-cobolcheck +++ b/exercises/practice/luhn/bin/fetch-cobolcheck @@ -4,7 +4,7 @@ # 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,7 +45,16 @@ get_download_url() { } main() { - output_path="/usr/local/bin/cobolcheck${ext}" + 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}" 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 3e9608d1..a57f708d 100644 --- a/exercises/practice/luhn/bin/fetch-cobolcheck.ps1 +++ b/exercises/practice/luhn/bin/fetch-cobolcheck.ps1 @@ -23,7 +23,5 @@ Function Get-DownloadUrl { } $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 +$outputFile = Join-Path -Path $PSScriptRoot -ChildPath "cobolcheck.exe" 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 16c73077..0b668734 100755 --- a/exercises/practice/matching-brackets/bin/fetch-cobolcheck +++ b/exercises/practice/matching-brackets/bin/fetch-cobolcheck @@ -4,7 +4,7 @@ # 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,7 +45,16 @@ get_download_url() { } main() { - output_path="/usr/local/bin/cobolcheck${ext}" + 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}" 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 3e9608d1..a57f708d 100644 --- a/exercises/practice/matching-brackets/bin/fetch-cobolcheck.ps1 +++ b/exercises/practice/matching-brackets/bin/fetch-cobolcheck.ps1 @@ -23,7 +23,5 @@ Function Get-DownloadUrl { } $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 +$outputFile = Join-Path -Path $PSScriptRoot -ChildPath "cobolcheck.exe" Invoke-WebRequest -Uri $downloadUrl -OutFile $outputFile @requestOpts diff --git a/exercises/practice/meetup/bin/fetch-cobolcheck b/exercises/practice/meetup/bin/fetch-cobolcheck index 16c73077..0b668734 100755 --- a/exercises/practice/meetup/bin/fetch-cobolcheck +++ b/exercises/practice/meetup/bin/fetch-cobolcheck @@ -4,7 +4,7 @@ # 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,7 +45,16 @@ get_download_url() { } main() { - output_path="/usr/local/bin/cobolcheck${ext}" + 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}" 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 3e9608d1..a57f708d 100644 --- a/exercises/practice/meetup/bin/fetch-cobolcheck.ps1 +++ b/exercises/practice/meetup/bin/fetch-cobolcheck.ps1 @@ -23,7 +23,5 @@ Function Get-DownloadUrl { } $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 +$outputFile = Join-Path -Path $PSScriptRoot -ChildPath "cobolcheck.exe" 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 16c73077..0b668734 100755 --- a/exercises/practice/nucleotide-count/bin/fetch-cobolcheck +++ b/exercises/practice/nucleotide-count/bin/fetch-cobolcheck @@ -4,7 +4,7 @@ # 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,7 +45,16 @@ get_download_url() { } main() { - output_path="/usr/local/bin/cobolcheck${ext}" + 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}" 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 3e9608d1..a57f708d 100644 --- a/exercises/practice/nucleotide-count/bin/fetch-cobolcheck.ps1 +++ b/exercises/practice/nucleotide-count/bin/fetch-cobolcheck.ps1 @@ -23,7 +23,5 @@ Function Get-DownloadUrl { } $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 +$outputFile = Join-Path -Path $PSScriptRoot -ChildPath "cobolcheck.exe" Invoke-WebRequest -Uri $downloadUrl -OutFile $outputFile @requestOpts diff --git a/exercises/practice/pangram/bin/fetch-cobolcheck b/exercises/practice/pangram/bin/fetch-cobolcheck index 16c73077..0b668734 100755 --- a/exercises/practice/pangram/bin/fetch-cobolcheck +++ b/exercises/practice/pangram/bin/fetch-cobolcheck @@ -4,7 +4,7 @@ # 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,7 +45,16 @@ get_download_url() { } main() { - output_path="/usr/local/bin/cobolcheck${ext}" + 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}" 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 3e9608d1..a57f708d 100644 --- a/exercises/practice/pangram/bin/fetch-cobolcheck.ps1 +++ b/exercises/practice/pangram/bin/fetch-cobolcheck.ps1 @@ -23,7 +23,5 @@ Function Get-DownloadUrl { } $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 +$outputFile = Join-Path -Path $PSScriptRoot -ChildPath "cobolcheck.exe" 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 16c73077..0b668734 100755 --- a/exercises/practice/pascals-triangle/bin/fetch-cobolcheck +++ b/exercises/practice/pascals-triangle/bin/fetch-cobolcheck @@ -4,7 +4,7 @@ # 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,7 +45,16 @@ get_download_url() { } main() { - output_path="/usr/local/bin/cobolcheck${ext}" + 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}" 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 3e9608d1..a57f708d 100644 --- a/exercises/practice/pascals-triangle/bin/fetch-cobolcheck.ps1 +++ b/exercises/practice/pascals-triangle/bin/fetch-cobolcheck.ps1 @@ -23,7 +23,5 @@ Function Get-DownloadUrl { } $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 +$outputFile = Join-Path -Path $PSScriptRoot -ChildPath "cobolcheck.exe" 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 16c73077..0b668734 100755 --- a/exercises/practice/pig-latin/bin/fetch-cobolcheck +++ b/exercises/practice/pig-latin/bin/fetch-cobolcheck @@ -4,7 +4,7 @@ # 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,7 +45,16 @@ get_download_url() { } main() { - output_path="/usr/local/bin/cobolcheck${ext}" + 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}" 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 3e9608d1..a57f708d 100644 --- a/exercises/practice/pig-latin/bin/fetch-cobolcheck.ps1 +++ b/exercises/practice/pig-latin/bin/fetch-cobolcheck.ps1 @@ -23,7 +23,5 @@ Function Get-DownloadUrl { } $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 +$outputFile = Join-Path -Path $PSScriptRoot -ChildPath "cobolcheck.exe" 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 16c73077..0b668734 100755 --- a/exercises/practice/protein-translation/bin/fetch-cobolcheck +++ b/exercises/practice/protein-translation/bin/fetch-cobolcheck @@ -4,7 +4,7 @@ # 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,7 +45,16 @@ get_download_url() { } main() { - output_path="/usr/local/bin/cobolcheck${ext}" + 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}" 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 3e9608d1..a57f708d 100644 --- a/exercises/practice/protein-translation/bin/fetch-cobolcheck.ps1 +++ b/exercises/practice/protein-translation/bin/fetch-cobolcheck.ps1 @@ -23,7 +23,5 @@ Function Get-DownloadUrl { } $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 +$outputFile = Join-Path -Path $PSScriptRoot -ChildPath "cobolcheck.exe" 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 16c73077..0b668734 100644 --- a/exercises/practice/queen-attack/bin/fetch-cobolcheck +++ b/exercises/practice/queen-attack/bin/fetch-cobolcheck @@ -4,7 +4,7 @@ # 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,7 +45,16 @@ get_download_url() { } main() { - output_path="/usr/local/bin/cobolcheck${ext}" + 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}" 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 3e9608d1..a57f708d 100644 --- a/exercises/practice/queen-attack/bin/fetch-cobolcheck.ps1 +++ b/exercises/practice/queen-attack/bin/fetch-cobolcheck.ps1 @@ -23,7 +23,5 @@ Function Get-DownloadUrl { } $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 +$outputFile = Join-Path -Path $PSScriptRoot -ChildPath "cobolcheck.exe" Invoke-WebRequest -Uri $downloadUrl -OutFile $outputFile @requestOpts diff --git a/exercises/practice/raindrops/bin/fetch-cobolcheck b/exercises/practice/raindrops/bin/fetch-cobolcheck index 16c73077..0b668734 100755 --- a/exercises/practice/raindrops/bin/fetch-cobolcheck +++ b/exercises/practice/raindrops/bin/fetch-cobolcheck @@ -4,7 +4,7 @@ # 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,7 +45,16 @@ get_download_url() { } main() { - output_path="/usr/local/bin/cobolcheck${ext}" + 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}" 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 3e9608d1..a57f708d 100644 --- a/exercises/practice/raindrops/bin/fetch-cobolcheck.ps1 +++ b/exercises/practice/raindrops/bin/fetch-cobolcheck.ps1 @@ -23,7 +23,5 @@ Function Get-DownloadUrl { } $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 +$outputFile = Join-Path -Path $PSScriptRoot -ChildPath "cobolcheck.exe" 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 16c73077..0b668734 100755 --- a/exercises/practice/reverse-string/bin/fetch-cobolcheck +++ b/exercises/practice/reverse-string/bin/fetch-cobolcheck @@ -4,7 +4,7 @@ # 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,7 +45,16 @@ get_download_url() { } main() { - output_path="/usr/local/bin/cobolcheck${ext}" + 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}" 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 3e9608d1..a57f708d 100644 --- a/exercises/practice/reverse-string/bin/fetch-cobolcheck.ps1 +++ b/exercises/practice/reverse-string/bin/fetch-cobolcheck.ps1 @@ -23,7 +23,5 @@ Function Get-DownloadUrl { } $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 +$outputFile = Join-Path -Path $PSScriptRoot -ChildPath "cobolcheck.exe" 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 16c73077..0b668734 100755 --- a/exercises/practice/rna-transcription/bin/fetch-cobolcheck +++ b/exercises/practice/rna-transcription/bin/fetch-cobolcheck @@ -4,7 +4,7 @@ # 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,7 +45,16 @@ get_download_url() { } main() { - output_path="/usr/local/bin/cobolcheck${ext}" + 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}" 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 3e9608d1..a57f708d 100644 --- a/exercises/practice/rna-transcription/bin/fetch-cobolcheck.ps1 +++ b/exercises/practice/rna-transcription/bin/fetch-cobolcheck.ps1 @@ -23,7 +23,5 @@ Function Get-DownloadUrl { } $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 +$outputFile = Join-Path -Path $PSScriptRoot -ChildPath "cobolcheck.exe" 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 16c73077..0b668734 100755 --- a/exercises/practice/robot-simulator/bin/fetch-cobolcheck +++ b/exercises/practice/robot-simulator/bin/fetch-cobolcheck @@ -4,7 +4,7 @@ # 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,7 +45,16 @@ get_download_url() { } main() { - output_path="/usr/local/bin/cobolcheck${ext}" + 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}" 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 3e9608d1..a57f708d 100644 --- a/exercises/practice/robot-simulator/bin/fetch-cobolcheck.ps1 +++ b/exercises/practice/robot-simulator/bin/fetch-cobolcheck.ps1 @@ -23,7 +23,5 @@ Function Get-DownloadUrl { } $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 +$outputFile = Join-Path -Path $PSScriptRoot -ChildPath "cobolcheck.exe" 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 16c73077..0b668734 100755 --- a/exercises/practice/roman-numerals/bin/fetch-cobolcheck +++ b/exercises/practice/roman-numerals/bin/fetch-cobolcheck @@ -4,7 +4,7 @@ # 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,7 +45,16 @@ get_download_url() { } main() { - output_path="/usr/local/bin/cobolcheck${ext}" + 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}" 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 3e9608d1..a57f708d 100644 --- a/exercises/practice/roman-numerals/bin/fetch-cobolcheck.ps1 +++ b/exercises/practice/roman-numerals/bin/fetch-cobolcheck.ps1 @@ -23,7 +23,5 @@ Function Get-DownloadUrl { } $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 +$outputFile = Join-Path -Path $PSScriptRoot -ChildPath "cobolcheck.exe" 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 16c73077..0b668734 100755 --- a/exercises/practice/rotational-cipher/bin/fetch-cobolcheck +++ b/exercises/practice/rotational-cipher/bin/fetch-cobolcheck @@ -4,7 +4,7 @@ # 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,7 +45,16 @@ get_download_url() { } main() { - output_path="/usr/local/bin/cobolcheck${ext}" + 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}" 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 3e9608d1..a57f708d 100644 --- a/exercises/practice/rotational-cipher/bin/fetch-cobolcheck.ps1 +++ b/exercises/practice/rotational-cipher/bin/fetch-cobolcheck.ps1 @@ -23,7 +23,5 @@ Function Get-DownloadUrl { } $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 +$outputFile = Join-Path -Path $PSScriptRoot -ChildPath "cobolcheck.exe" 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 16c73077..0b668734 100644 --- a/exercises/practice/scrabble-score/bin/fetch-cobolcheck +++ b/exercises/practice/scrabble-score/bin/fetch-cobolcheck @@ -4,7 +4,7 @@ # 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,7 +45,16 @@ get_download_url() { } main() { - output_path="/usr/local/bin/cobolcheck${ext}" + 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}" 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 3e9608d1..a57f708d 100644 --- a/exercises/practice/scrabble-score/bin/fetch-cobolcheck.ps1 +++ b/exercises/practice/scrabble-score/bin/fetch-cobolcheck.ps1 @@ -23,7 +23,5 @@ Function Get-DownloadUrl { } $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 +$outputFile = Join-Path -Path $PSScriptRoot -ChildPath "cobolcheck.exe" 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 16c73077..0b668734 100755 --- a/exercises/practice/secret-handshake/bin/fetch-cobolcheck +++ b/exercises/practice/secret-handshake/bin/fetch-cobolcheck @@ -4,7 +4,7 @@ # 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,7 +45,16 @@ get_download_url() { } main() { - output_path="/usr/local/bin/cobolcheck${ext}" + 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}" 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 3e9608d1..a57f708d 100644 --- a/exercises/practice/secret-handshake/bin/fetch-cobolcheck.ps1 +++ b/exercises/practice/secret-handshake/bin/fetch-cobolcheck.ps1 @@ -23,7 +23,5 @@ Function Get-DownloadUrl { } $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 +$outputFile = Join-Path -Path $PSScriptRoot -ChildPath "cobolcheck.exe" Invoke-WebRequest -Uri $downloadUrl -OutFile $outputFile @requestOpts diff --git a/exercises/practice/sieve/bin/fetch-cobolcheck b/exercises/practice/sieve/bin/fetch-cobolcheck index 16c73077..0b668734 100755 --- a/exercises/practice/sieve/bin/fetch-cobolcheck +++ b/exercises/practice/sieve/bin/fetch-cobolcheck @@ -4,7 +4,7 @@ # 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,7 +45,16 @@ get_download_url() { } main() { - output_path="/usr/local/bin/cobolcheck${ext}" + 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}" 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 3e9608d1..a57f708d 100644 --- a/exercises/practice/sieve/bin/fetch-cobolcheck.ps1 +++ b/exercises/practice/sieve/bin/fetch-cobolcheck.ps1 @@ -23,7 +23,5 @@ Function Get-DownloadUrl { } $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 +$outputFile = Join-Path -Path $PSScriptRoot -ChildPath "cobolcheck.exe" 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 16c73077..0b668734 100755 --- a/exercises/practice/space-age/bin/fetch-cobolcheck +++ b/exercises/practice/space-age/bin/fetch-cobolcheck @@ -4,7 +4,7 @@ # 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,7 +45,16 @@ get_download_url() { } main() { - output_path="/usr/local/bin/cobolcheck${ext}" + 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}" 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 3e9608d1..a57f708d 100644 --- a/exercises/practice/space-age/bin/fetch-cobolcheck.ps1 +++ b/exercises/practice/space-age/bin/fetch-cobolcheck.ps1 @@ -23,7 +23,5 @@ Function Get-DownloadUrl { } $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 +$outputFile = Join-Path -Path $PSScriptRoot -ChildPath "cobolcheck.exe" 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 16c73077..0b668734 100755 --- a/exercises/practice/square-root/bin/fetch-cobolcheck +++ b/exercises/practice/square-root/bin/fetch-cobolcheck @@ -4,7 +4,7 @@ # 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,7 +45,16 @@ get_download_url() { } main() { - output_path="/usr/local/bin/cobolcheck${ext}" + 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}" 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 3e9608d1..a57f708d 100644 --- a/exercises/practice/square-root/bin/fetch-cobolcheck.ps1 +++ b/exercises/practice/square-root/bin/fetch-cobolcheck.ps1 @@ -23,7 +23,5 @@ Function Get-DownloadUrl { } $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 +$outputFile = Join-Path -Path $PSScriptRoot -ChildPath "cobolcheck.exe" Invoke-WebRequest -Uri $downloadUrl -OutFile $outputFile @requestOpts diff --git a/exercises/practice/triangle/bin/fetch-cobolcheck b/exercises/practice/triangle/bin/fetch-cobolcheck index 16c73077..0b668734 100644 --- a/exercises/practice/triangle/bin/fetch-cobolcheck +++ b/exercises/practice/triangle/bin/fetch-cobolcheck @@ -4,7 +4,7 @@ # 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,7 +45,16 @@ get_download_url() { } main() { - output_path="/usr/local/bin/cobolcheck${ext}" + 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}" 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 3e9608d1..a57f708d 100644 --- a/exercises/practice/triangle/bin/fetch-cobolcheck.ps1 +++ b/exercises/practice/triangle/bin/fetch-cobolcheck.ps1 @@ -23,7 +23,5 @@ Function Get-DownloadUrl { } $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 +$outputFile = Join-Path -Path $PSScriptRoot -ChildPath "cobolcheck.exe" 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 16c73077..0b668734 100755 --- a/exercises/practice/two-fer/bin/fetch-cobolcheck +++ b/exercises/practice/two-fer/bin/fetch-cobolcheck @@ -4,7 +4,7 @@ # 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,7 +45,16 @@ get_download_url() { } main() { - output_path="/usr/local/bin/cobolcheck${ext}" + 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}" 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 3e9608d1..a57f708d 100644 --- a/exercises/practice/two-fer/bin/fetch-cobolcheck.ps1 +++ b/exercises/practice/two-fer/bin/fetch-cobolcheck.ps1 @@ -23,7 +23,5 @@ Function Get-DownloadUrl { } $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 +$outputFile = Join-Path -Path $PSScriptRoot -ChildPath "cobolcheck.exe" Invoke-WebRequest -Uri $downloadUrl -OutFile $outputFile @requestOpts diff --git a/exercises/practice/yacht/bin/fetch-cobolcheck b/exercises/practice/yacht/bin/fetch-cobolcheck index 16c73077..0b668734 100755 --- a/exercises/practice/yacht/bin/fetch-cobolcheck +++ b/exercises/practice/yacht/bin/fetch-cobolcheck @@ -4,7 +4,7 @@ # 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,7 +45,16 @@ get_download_url() { } main() { - output_path="/usr/local/bin/cobolcheck${ext}" + 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}" 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 3e9608d1..a57f708d 100644 --- a/exercises/practice/yacht/bin/fetch-cobolcheck.ps1 +++ b/exercises/practice/yacht/bin/fetch-cobolcheck.ps1 @@ -23,7 +23,5 @@ Function Get-DownloadUrl { } $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 +$outputFile = Join-Path -Path $PSScriptRoot -ChildPath "cobolcheck.exe" Invoke-WebRequest -Uri $downloadUrl -OutFile $outputFile @requestOpts From 229c7369d5e33a4bcb2694ba73cf4eb4044a7aa1 Mon Sep 17 00:00:00 2001 From: SimaDovakin Date: Sat, 10 Aug 2024 17:44:33 +0300 Subject: [PATCH 2/4] fetch-cobolcheck-fixes: - Renamed bin/sync-fetch-cobolcheck-files to bin/sync-exercise-files and added synchronization for test.sh and test.ps1 files. - Added bin/exercise_test.sh and bin/exercise_test.ps1 as templates for test.sh and test.ps1 respectively. - Changed cobolcheck location to $HOME/cobolcheck/cobolcheck{,exe}. --- bin/exercise_test.ps1 | 19 +++++++++++++++++++ bin/exercise_test.sh | 16 ++++++++++++++++ bin/fetch-cobolcheck | 12 +++--------- bin/fetch-cobolcheck.ps1 | 2 +- ...h-cobolcheck-files => sync-exercise-files} | 2 ++ .../practice/acronym/bin/fetch-cobolcheck | 12 +++--------- .../practice/acronym/bin/fetch-cobolcheck.ps1 | 2 +- exercises/practice/acronym/test.ps1 | 12 +++++------- exercises/practice/acronym/test.sh | 8 ++------ .../all-your-base/bin/fetch-cobolcheck | 12 +++--------- .../all-your-base/bin/fetch-cobolcheck.ps1 | 2 +- exercises/practice/all-your-base/test.ps1 | 12 +++++------- exercises/practice/all-your-base/test.sh | 8 ++------ .../practice/allergies/bin/fetch-cobolcheck | 12 +++--------- .../allergies/bin/fetch-cobolcheck.ps1 | 2 +- exercises/practice/allergies/test.ps1 | 12 +++++------- exercises/practice/allergies/test.sh | 8 ++------ .../practice/anagram/bin/fetch-cobolcheck | 12 +++--------- .../practice/anagram/bin/fetch-cobolcheck.ps1 | 2 +- exercises/practice/anagram/test.ps1 | 12 +++++------- exercises/practice/anagram/test.sh | 8 ++------ .../armstrong-numbers/bin/fetch-cobolcheck | 12 +++--------- .../bin/fetch-cobolcheck.ps1 | 2 +- exercises/practice/armstrong-numbers/test.ps1 | 12 +++++------- exercises/practice/armstrong-numbers/test.sh | 8 ++------ .../atbash-cipher/bin/fetch-cobolcheck | 12 +++--------- .../atbash-cipher/bin/fetch-cobolcheck.ps1 | 2 +- exercises/practice/atbash-cipher/test.ps1 | 12 +++++------- exercises/practice/atbash-cipher/test.sh | 8 ++------ .../binary-search/bin/fetch-cobolcheck | 12 +++--------- .../binary-search/bin/fetch-cobolcheck.ps1 | 2 +- exercises/practice/binary-search/test.ps1 | 9 ++++++--- exercises/practice/binary-search/test.sh | 8 ++------ .../practice/binary/bin/fetch-cobolcheck | 12 +++--------- .../practice/binary/bin/fetch-cobolcheck.ps1 | 2 +- exercises/practice/binary/test.ps1 | 12 +++++------- exercises/practice/binary/test.sh | 8 ++------ exercises/practice/bob/bin/fetch-cobolcheck | 12 +++--------- .../practice/bob/bin/fetch-cobolcheck.ps1 | 2 +- exercises/practice/bob/test.ps1 | 12 +++++------- exercises/practice/bob/test.sh | 8 ++------ .../circular-buffer/bin/fetch-cobolcheck | 12 +++--------- .../circular-buffer/bin/fetch-cobolcheck.ps1 | 2 +- exercises/practice/circular-buffer/test.ps1 | 12 +++++------- exercises/practice/circular-buffer/test.sh | 8 ++------ .../collatz-conjecture/bin/fetch-cobolcheck | 12 +++--------- .../bin/fetch-cobolcheck.ps1 | 2 +- .../practice/collatz-conjecture/test.ps1 | 12 +++++------- exercises/practice/collatz-conjecture/test.sh | 8 ++------ .../complex-numbers/bin/fetch-cobolcheck | 12 +++--------- .../complex-numbers/bin/fetch-cobolcheck.ps1 | 2 +- exercises/practice/complex-numbers/test.ps1 | 12 +++++------- exercises/practice/complex-numbers/test.sh | 8 ++------ exercises/practice/darts/bin/fetch-cobolcheck | 12 +++--------- .../practice/darts/bin/fetch-cobolcheck.ps1 | 2 +- exercises/practice/darts/test.ps1 | 12 +++++------- exercises/practice/darts/test.sh | 8 ++------ .../practice/diamond/bin/fetch-cobolcheck | 12 +++--------- .../practice/diamond/bin/fetch-cobolcheck.ps1 | 2 +- exercises/practice/diamond/test.ps1 | 12 +++++------- exercises/practice/diamond/test.sh | 8 ++------ .../bin/fetch-cobolcheck | 12 +++--------- .../bin/fetch-cobolcheck.ps1 | 2 +- .../practice/difference-of-squares/test.ps1 | 12 +++++------- .../practice/difference-of-squares/test.sh | 8 ++------ .../practice/eliuds-eggs/bin/fetch-cobolcheck | 12 +++--------- .../eliuds-eggs/bin/fetch-cobolcheck.ps1 | 2 +- exercises/practice/eliuds-eggs/test.ps1 | 12 +++++------- exercises/practice/eliuds-eggs/test.sh | 8 ++------ .../grade-school/bin/fetch-cobolcheck | 12 +++--------- .../grade-school/bin/fetch-cobolcheck.ps1 | 2 +- exercises/practice/grade-school/test.ps1 | 12 +++++------- exercises/practice/grade-school/test.sh | 8 ++------ .../practice/hamming/bin/fetch-cobolcheck | 12 +++--------- .../practice/hamming/bin/fetch-cobolcheck.ps1 | 2 +- exercises/practice/hamming/test.ps1 | 12 +++++------- exercises/practice/hamming/test.sh | 9 ++------- .../practice/hello-world/bin/fetch-cobolcheck | 12 +++--------- .../hello-world/bin/fetch-cobolcheck.ps1 | 2 +- exercises/practice/hello-world/test.ps1 | 12 +++++------- exercises/practice/hello-world/test.sh | 8 ++------ .../practice/high-scores/bin/fetch-cobolcheck | 12 +++--------- .../high-scores/bin/fetch-cobolcheck.ps1 | 2 +- exercises/practice/high-scores/test.ps1 | 12 +++++------- exercises/practice/high-scores/test.sh | 8 ++------ .../practice/isogram/bin/fetch-cobolcheck | 12 +++--------- .../practice/isogram/bin/fetch-cobolcheck.ps1 | 2 +- exercises/practice/isogram/test.ps1 | 12 +++++------- exercises/practice/isogram/test.sh | 8 ++------ .../practice/knapsack/bin/fetch-cobolcheck | 12 +++--------- .../knapsack/bin/fetch-cobolcheck.ps1 | 2 +- exercises/practice/knapsack/test.ps1 | 12 +++++------- exercises/practice/knapsack/test.sh | 8 ++------ exercises/practice/leap/bin/fetch-cobolcheck | 12 +++--------- .../practice/leap/bin/fetch-cobolcheck.ps1 | 2 +- exercises/practice/leap/test.ps1 | 12 +++++------- exercises/practice/leap/test.sh | 10 +++------- exercises/practice/luhn/bin/fetch-cobolcheck | 12 +++--------- .../practice/luhn/bin/fetch-cobolcheck.ps1 | 2 +- exercises/practice/luhn/test.ps1 | 12 +++++------- exercises/practice/luhn/test.sh | 8 ++------ .../matching-brackets/bin/fetch-cobolcheck | 12 +++--------- .../bin/fetch-cobolcheck.ps1 | 2 +- exercises/practice/matching-brackets/test.ps1 | 12 +++++------- exercises/practice/matching-brackets/test.sh | 8 ++------ .../practice/meetup/bin/fetch-cobolcheck | 12 +++--------- .../practice/meetup/bin/fetch-cobolcheck.ps1 | 2 +- exercises/practice/meetup/test.ps1 | 9 ++++++--- exercises/practice/meetup/test.sh | 8 ++------ .../nucleotide-count/bin/fetch-cobolcheck | 12 +++--------- .../nucleotide-count/bin/fetch-cobolcheck.ps1 | 2 +- exercises/practice/nucleotide-count/test.ps1 | 12 +++++------- exercises/practice/nucleotide-count/test.sh | 9 ++------- .../practice/pangram/bin/fetch-cobolcheck | 12 +++--------- .../practice/pangram/bin/fetch-cobolcheck.ps1 | 2 +- exercises/practice/pangram/test.ps1 | 12 +++++------- exercises/practice/pangram/test.sh | 8 ++------ .../pascals-triangle/bin/fetch-cobolcheck | 12 +++--------- .../pascals-triangle/bin/fetch-cobolcheck.ps1 | 2 +- exercises/practice/pascals-triangle/test.ps1 | 12 +++++------- exercises/practice/pascals-triangle/test.sh | 8 ++------ .../practice/pig-latin/bin/fetch-cobolcheck | 12 +++--------- .../pig-latin/bin/fetch-cobolcheck.ps1 | 2 +- exercises/practice/pig-latin/test.ps1 | 9 ++++++--- exercises/practice/pig-latin/test.sh | 8 ++------ .../protein-translation/bin/fetch-cobolcheck | 12 +++--------- .../bin/fetch-cobolcheck.ps1 | 2 +- .../practice/protein-translation/test.ps1 | 9 ++++++--- .../practice/protein-translation/test.sh | 8 ++------ .../queen-attack/bin/fetch-cobolcheck | 12 +++--------- .../queen-attack/bin/fetch-cobolcheck.ps1 | 2 +- exercises/practice/queen-attack/test.ps1 | 12 +++++------- exercises/practice/queen-attack/test.sh | 8 ++------ .../practice/raindrops/bin/fetch-cobolcheck | 12 +++--------- .../raindrops/bin/fetch-cobolcheck.ps1 | 2 +- exercises/practice/raindrops/test.ps1 | 12 +++++------- exercises/practice/raindrops/test.sh | 8 ++------ .../reverse-string/bin/fetch-cobolcheck | 12 +++--------- .../reverse-string/bin/fetch-cobolcheck.ps1 | 2 +- exercises/practice/reverse-string/test.ps1 | 12 +++++------- exercises/practice/reverse-string/test.sh | 8 ++------ .../rna-transcription/bin/fetch-cobolcheck | 12 +++--------- .../bin/fetch-cobolcheck.ps1 | 2 +- exercises/practice/rna-transcription/test.ps1 | 12 +++++------- exercises/practice/rna-transcription/test.sh | 8 ++------ .../robot-simulator/bin/fetch-cobolcheck | 12 +++--------- .../robot-simulator/bin/fetch-cobolcheck.ps1 | 2 +- exercises/practice/robot-simulator/test.ps1 | 9 ++++++--- exercises/practice/robot-simulator/test.sh | 8 ++------ .../roman-numerals/bin/fetch-cobolcheck | 12 +++--------- .../roman-numerals/bin/fetch-cobolcheck.ps1 | 2 +- exercises/practice/roman-numerals/test.ps1 | 12 +++++------- exercises/practice/roman-numerals/test.sh | 8 ++------ .../rotational-cipher/bin/fetch-cobolcheck | 12 +++--------- .../bin/fetch-cobolcheck.ps1 | 2 +- exercises/practice/rotational-cipher/test.ps1 | 12 +++++------- exercises/practice/rotational-cipher/test.sh | 8 ++------ .../scrabble-score/bin/fetch-cobolcheck | 12 +++--------- .../scrabble-score/bin/fetch-cobolcheck.ps1 | 2 +- exercises/practice/scrabble-score/test.ps1 | 12 +++++------- exercises/practice/scrabble-score/test.sh | 8 ++------ .../secret-handshake/bin/fetch-cobolcheck | 12 +++--------- .../secret-handshake/bin/fetch-cobolcheck.ps1 | 2 +- exercises/practice/secret-handshake/test.ps1 | 9 ++++++--- exercises/practice/secret-handshake/test.sh | 8 ++------ exercises/practice/sieve/bin/fetch-cobolcheck | 12 +++--------- .../practice/sieve/bin/fetch-cobolcheck.ps1 | 2 +- exercises/practice/sieve/test.ps1 | 12 +++++------- exercises/practice/sieve/test.sh | 8 ++------ .../practice/space-age/bin/fetch-cobolcheck | 12 +++--------- .../space-age/bin/fetch-cobolcheck.ps1 | 2 +- exercises/practice/space-age/test.ps1 | 9 ++++++--- exercises/practice/space-age/test.sh | 8 ++------ .../practice/square-root/bin/fetch-cobolcheck | 12 +++--------- .../square-root/bin/fetch-cobolcheck.ps1 | 2 +- exercises/practice/square-root/test.ps1 | 12 +++++------- exercises/practice/square-root/test.sh | 8 ++------ .../practice/triangle/bin/fetch-cobolcheck | 12 +++--------- .../triangle/bin/fetch-cobolcheck.ps1 | 2 +- exercises/practice/triangle/test.ps1 | 12 +++++------- exercises/practice/triangle/test.sh | 8 ++------ .../practice/two-fer/bin/fetch-cobolcheck | 12 +++--------- .../practice/two-fer/bin/fetch-cobolcheck.ps1 | 2 +- exercises/practice/two-fer/test.ps1 | 12 +++++------- exercises/practice/two-fer/test.sh | 8 ++------ exercises/practice/yacht/bin/fetch-cobolcheck | 12 +++--------- .../practice/yacht/bin/fetch-cobolcheck.ps1 | 2 +- exercises/practice/yacht/test.ps1 | 12 +++++------- exercises/practice/yacht/test.sh | 8 ++------ 189 files changed, 555 insertions(+), 1043 deletions(-) create mode 100644 bin/exercise_test.ps1 create mode 100755 bin/exercise_test.sh rename bin/{sync-fetch-cobolcheck-files => sync-exercise-files} (68%) mode change 100644 => 100755 exercises/practice/acronym/test.sh mode change 100644 => 100755 exercises/practice/anagram/test.sh diff --git a/bin/exercise_test.ps1 b/bin/exercise_test.ps1 new file mode 100644 index 00000000..7a2bb33b --- /dev/null +++ b/bin/exercise_test.ps1 @@ -0,0 +1,19 @@ +$slug=Split-Path $PSScriptRoot -Leaf +$cobolcheck = Join-Path -Path "${HOME}" "cobolcheck" "cobolcheck.exe" + +if (![System.IO.File]::Exists("$cobolcheck")){ + $fetchCobolcheckPath = Join-Path -Path "${PSScriptRoot}" "bin" "fetch-cobolcheck.ps1" + echo $fetchCobolcheckPath + Write-Output "Cobolcheck not found. Trying to fetch it." + & "${fetchCobolcheckPath}" +} + +Write-Output "Run cobolcheck." +Set-Location $PSScriptRoot + +Invoke-Expression "$cobolcheck -p $slug" +Invoke-Expression "cobc -xj test.cob" + +if ($Lastexitcode -ne 0) { + exit $Lastexitcode +} diff --git a/bin/exercise_test.sh b/bin/exercise_test.sh new file mode 100755 index 00000000..7b4a9da0 --- /dev/null +++ b/bin/exercise_test.sh @@ -0,0 +1,16 @@ +#!/usr/bin/env bash +SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )/ +SLUG=${1:-$(basename "${SCRIPT_DIR}")} +COBOLCHECK="${HOME}/cobolcheck/cobolcheck" + +if [ ! -f "${COBOLCHECK}" ]; then + echo "Cobolcheck not found, try to fetch it." + cd $SCRIPT_DIR/bin/ + bash fetch-cobolcheck +fi +cd $SCRIPT_DIR +$COBOLCHECK -p $SLUG + +# compile and run +echo "COMPILE AND RUN TEST" +cobc -xj test.cob diff --git a/bin/fetch-cobolcheck b/bin/fetch-cobolcheck index 0b668734..b3d4adb1 100755 --- a/bin/fetch-cobolcheck +++ b/bin/fetch-cobolcheck @@ -45,19 +45,13 @@ 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_dir="${HOME}/cobolcheck" + mkdir -p "${output_dir}" output_path="${output_dir}/cobolcheck${ext}" download_url="$(get_download_url)" curl "${curlopts[@]}" --output "${output_path}" "${download_url}" chmod +x "${output_path}" + echo "Cobolcheck has been downloaded to ${output_path}" } main diff --git a/bin/fetch-cobolcheck.ps1 b/bin/fetch-cobolcheck.ps1 index a57f708d..9228452c 100644 --- a/bin/fetch-cobolcheck.ps1 +++ b/bin/fetch-cobolcheck.ps1 @@ -23,5 +23,5 @@ Function Get-DownloadUrl { } $downloadUrl = Get-DownloadUrl -$outputFile = Join-Path -Path $PSScriptRoot -ChildPath "cobolcheck.exe" +$outputFile = Join-Path -Path "${HOME}" "cobolcheck" "cobolcheck.exe" Invoke-WebRequest -Uri $downloadUrl -OutFile $outputFile @requestOpts diff --git a/bin/sync-fetch-cobolcheck-files b/bin/sync-exercise-files similarity index 68% rename from bin/sync-fetch-cobolcheck-files rename to bin/sync-exercise-files index 6400e009..64b9b571 100755 --- a/bin/sync-fetch-cobolcheck-files +++ b/bin/sync-exercise-files @@ -7,4 +7,6 @@ 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 + cp "bin/exercise_test.sh" "${test_dir}/test.sh" + cp "bin/exercise_test.ps1" "${test_dir}/test.ps1" done diff --git a/exercises/practice/acronym/bin/fetch-cobolcheck b/exercises/practice/acronym/bin/fetch-cobolcheck index 0b668734..b3d4adb1 100755 --- a/exercises/practice/acronym/bin/fetch-cobolcheck +++ b/exercises/practice/acronym/bin/fetch-cobolcheck @@ -45,19 +45,13 @@ 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_dir="${HOME}/cobolcheck" + mkdir -p "${output_dir}" output_path="${output_dir}/cobolcheck${ext}" download_url="$(get_download_url)" curl "${curlopts[@]}" --output "${output_path}" "${download_url}" chmod +x "${output_path}" + echo "Cobolcheck has been downloaded to ${output_path}" } main diff --git a/exercises/practice/acronym/bin/fetch-cobolcheck.ps1 b/exercises/practice/acronym/bin/fetch-cobolcheck.ps1 index a57f708d..9228452c 100644 --- a/exercises/practice/acronym/bin/fetch-cobolcheck.ps1 +++ b/exercises/practice/acronym/bin/fetch-cobolcheck.ps1 @@ -23,5 +23,5 @@ Function Get-DownloadUrl { } $downloadUrl = Get-DownloadUrl -$outputFile = Join-Path -Path $PSScriptRoot -ChildPath "cobolcheck.exe" +$outputFile = Join-Path -Path "${HOME}" "cobolcheck" "cobolcheck.exe" Invoke-WebRequest -Uri $downloadUrl -OutFile $outputFile @requestOpts diff --git a/exercises/practice/acronym/test.ps1 b/exercises/practice/acronym/test.ps1 index b54fdc61..7a2bb33b 100644 --- a/exercises/practice/acronym/test.ps1 +++ b/exercises/practice/acronym/test.ps1 @@ -1,13 +1,11 @@ $slug=Split-Path $PSScriptRoot -Leaf -$cobolcheck = "$PSScriptRoot\bin\cobolcheck.exe" -$cobolcheckCmd = Get-Command "cobolcheck.exe" -ErrorAction SilentlyContinue +$cobolcheck = Join-Path -Path "${HOME}" "cobolcheck" "cobolcheck.exe" -if ($cobolcheckCmd) { - $cobolcheck = $cobolcheckCmd.Path - Write-Output "Found cobolcheck, using $cobolcheck" -} elseif (![System.IO.File]::Exists("$cobolcheck")){ +if (![System.IO.File]::Exists("$cobolcheck")){ + $fetchCobolcheckPath = Join-Path -Path "${PSScriptRoot}" "bin" "fetch-cobolcheck.ps1" + echo $fetchCobolcheckPath Write-Output "Cobolcheck not found. Trying to fetch it." - & "$PSScriptRoot\bin\fetch-cobolcheck.ps1" + & "${fetchCobolcheckPath}" } Write-Output "Run cobolcheck." diff --git a/exercises/practice/acronym/test.sh b/exercises/practice/acronym/test.sh old mode 100644 new mode 100755 index ed4a27a1..7b4a9da0 --- a/exercises/practice/acronym/test.sh +++ b/exercises/practice/acronym/test.sh @@ -1,13 +1,9 @@ #!/usr/bin/env bash SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )/ SLUG=${1:-$(basename "${SCRIPT_DIR}")} -COBOLCHECK=./bin/cobolcheck +COBOLCHECK="${HOME}/cobolcheck/cobolcheck" -WHICH_COBOLCHECK=$(which cobolcheck) -if [[ $? -eq 0 ]] ; then - echo "Found cobolcheck, using $COBOLCHECK" - COBOLCHECK=$WHICH_COBOLCHECK -elif [ ! -f $SCRIPT_DIR/bin/cobolcheck ]; then +if [ ! -f "${COBOLCHECK}" ]; then echo "Cobolcheck not found, try to fetch it." cd $SCRIPT_DIR/bin/ bash fetch-cobolcheck diff --git a/exercises/practice/all-your-base/bin/fetch-cobolcheck b/exercises/practice/all-your-base/bin/fetch-cobolcheck index 0b668734..b3d4adb1 100755 --- a/exercises/practice/all-your-base/bin/fetch-cobolcheck +++ b/exercises/practice/all-your-base/bin/fetch-cobolcheck @@ -45,19 +45,13 @@ 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_dir="${HOME}/cobolcheck" + mkdir -p "${output_dir}" output_path="${output_dir}/cobolcheck${ext}" download_url="$(get_download_url)" curl "${curlopts[@]}" --output "${output_path}" "${download_url}" chmod +x "${output_path}" + echo "Cobolcheck has been downloaded to ${output_path}" } main diff --git a/exercises/practice/all-your-base/bin/fetch-cobolcheck.ps1 b/exercises/practice/all-your-base/bin/fetch-cobolcheck.ps1 index a57f708d..9228452c 100644 --- a/exercises/practice/all-your-base/bin/fetch-cobolcheck.ps1 +++ b/exercises/practice/all-your-base/bin/fetch-cobolcheck.ps1 @@ -23,5 +23,5 @@ Function Get-DownloadUrl { } $downloadUrl = Get-DownloadUrl -$outputFile = Join-Path -Path $PSScriptRoot -ChildPath "cobolcheck.exe" +$outputFile = Join-Path -Path "${HOME}" "cobolcheck" "cobolcheck.exe" Invoke-WebRequest -Uri $downloadUrl -OutFile $outputFile @requestOpts diff --git a/exercises/practice/all-your-base/test.ps1 b/exercises/practice/all-your-base/test.ps1 index b54fdc61..7a2bb33b 100644 --- a/exercises/practice/all-your-base/test.ps1 +++ b/exercises/practice/all-your-base/test.ps1 @@ -1,13 +1,11 @@ $slug=Split-Path $PSScriptRoot -Leaf -$cobolcheck = "$PSScriptRoot\bin\cobolcheck.exe" -$cobolcheckCmd = Get-Command "cobolcheck.exe" -ErrorAction SilentlyContinue +$cobolcheck = Join-Path -Path "${HOME}" "cobolcheck" "cobolcheck.exe" -if ($cobolcheckCmd) { - $cobolcheck = $cobolcheckCmd.Path - Write-Output "Found cobolcheck, using $cobolcheck" -} elseif (![System.IO.File]::Exists("$cobolcheck")){ +if (![System.IO.File]::Exists("$cobolcheck")){ + $fetchCobolcheckPath = Join-Path -Path "${PSScriptRoot}" "bin" "fetch-cobolcheck.ps1" + echo $fetchCobolcheckPath Write-Output "Cobolcheck not found. Trying to fetch it." - & "$PSScriptRoot\bin\fetch-cobolcheck.ps1" + & "${fetchCobolcheckPath}" } Write-Output "Run cobolcheck." diff --git a/exercises/practice/all-your-base/test.sh b/exercises/practice/all-your-base/test.sh index ed4a27a1..7b4a9da0 100644 --- a/exercises/practice/all-your-base/test.sh +++ b/exercises/practice/all-your-base/test.sh @@ -1,13 +1,9 @@ #!/usr/bin/env bash SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )/ SLUG=${1:-$(basename "${SCRIPT_DIR}")} -COBOLCHECK=./bin/cobolcheck +COBOLCHECK="${HOME}/cobolcheck/cobolcheck" -WHICH_COBOLCHECK=$(which cobolcheck) -if [[ $? -eq 0 ]] ; then - echo "Found cobolcheck, using $COBOLCHECK" - COBOLCHECK=$WHICH_COBOLCHECK -elif [ ! -f $SCRIPT_DIR/bin/cobolcheck ]; then +if [ ! -f "${COBOLCHECK}" ]; then echo "Cobolcheck not found, try to fetch it." cd $SCRIPT_DIR/bin/ bash fetch-cobolcheck diff --git a/exercises/practice/allergies/bin/fetch-cobolcheck b/exercises/practice/allergies/bin/fetch-cobolcheck index 0b668734..b3d4adb1 100755 --- a/exercises/practice/allergies/bin/fetch-cobolcheck +++ b/exercises/practice/allergies/bin/fetch-cobolcheck @@ -45,19 +45,13 @@ 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_dir="${HOME}/cobolcheck" + mkdir -p "${output_dir}" output_path="${output_dir}/cobolcheck${ext}" download_url="$(get_download_url)" curl "${curlopts[@]}" --output "${output_path}" "${download_url}" chmod +x "${output_path}" + echo "Cobolcheck has been downloaded to ${output_path}" } main diff --git a/exercises/practice/allergies/bin/fetch-cobolcheck.ps1 b/exercises/practice/allergies/bin/fetch-cobolcheck.ps1 index a57f708d..9228452c 100644 --- a/exercises/practice/allergies/bin/fetch-cobolcheck.ps1 +++ b/exercises/practice/allergies/bin/fetch-cobolcheck.ps1 @@ -23,5 +23,5 @@ Function Get-DownloadUrl { } $downloadUrl = Get-DownloadUrl -$outputFile = Join-Path -Path $PSScriptRoot -ChildPath "cobolcheck.exe" +$outputFile = Join-Path -Path "${HOME}" "cobolcheck" "cobolcheck.exe" Invoke-WebRequest -Uri $downloadUrl -OutFile $outputFile @requestOpts diff --git a/exercises/practice/allergies/test.ps1 b/exercises/practice/allergies/test.ps1 index b54fdc61..7a2bb33b 100644 --- a/exercises/practice/allergies/test.ps1 +++ b/exercises/practice/allergies/test.ps1 @@ -1,13 +1,11 @@ $slug=Split-Path $PSScriptRoot -Leaf -$cobolcheck = "$PSScriptRoot\bin\cobolcheck.exe" -$cobolcheckCmd = Get-Command "cobolcheck.exe" -ErrorAction SilentlyContinue +$cobolcheck = Join-Path -Path "${HOME}" "cobolcheck" "cobolcheck.exe" -if ($cobolcheckCmd) { - $cobolcheck = $cobolcheckCmd.Path - Write-Output "Found cobolcheck, using $cobolcheck" -} elseif (![System.IO.File]::Exists("$cobolcheck")){ +if (![System.IO.File]::Exists("$cobolcheck")){ + $fetchCobolcheckPath = Join-Path -Path "${PSScriptRoot}" "bin" "fetch-cobolcheck.ps1" + echo $fetchCobolcheckPath Write-Output "Cobolcheck not found. Trying to fetch it." - & "$PSScriptRoot\bin\fetch-cobolcheck.ps1" + & "${fetchCobolcheckPath}" } Write-Output "Run cobolcheck." diff --git a/exercises/practice/allergies/test.sh b/exercises/practice/allergies/test.sh index ed4a27a1..7b4a9da0 100644 --- a/exercises/practice/allergies/test.sh +++ b/exercises/practice/allergies/test.sh @@ -1,13 +1,9 @@ #!/usr/bin/env bash SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )/ SLUG=${1:-$(basename "${SCRIPT_DIR}")} -COBOLCHECK=./bin/cobolcheck +COBOLCHECK="${HOME}/cobolcheck/cobolcheck" -WHICH_COBOLCHECK=$(which cobolcheck) -if [[ $? -eq 0 ]] ; then - echo "Found cobolcheck, using $COBOLCHECK" - COBOLCHECK=$WHICH_COBOLCHECK -elif [ ! -f $SCRIPT_DIR/bin/cobolcheck ]; then +if [ ! -f "${COBOLCHECK}" ]; then echo "Cobolcheck not found, try to fetch it." cd $SCRIPT_DIR/bin/ bash fetch-cobolcheck diff --git a/exercises/practice/anagram/bin/fetch-cobolcheck b/exercises/practice/anagram/bin/fetch-cobolcheck index 0b668734..b3d4adb1 100755 --- a/exercises/practice/anagram/bin/fetch-cobolcheck +++ b/exercises/practice/anagram/bin/fetch-cobolcheck @@ -45,19 +45,13 @@ 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_dir="${HOME}/cobolcheck" + mkdir -p "${output_dir}" output_path="${output_dir}/cobolcheck${ext}" download_url="$(get_download_url)" curl "${curlopts[@]}" --output "${output_path}" "${download_url}" chmod +x "${output_path}" + echo "Cobolcheck has been downloaded to ${output_path}" } main diff --git a/exercises/practice/anagram/bin/fetch-cobolcheck.ps1 b/exercises/practice/anagram/bin/fetch-cobolcheck.ps1 index a57f708d..9228452c 100644 --- a/exercises/practice/anagram/bin/fetch-cobolcheck.ps1 +++ b/exercises/practice/anagram/bin/fetch-cobolcheck.ps1 @@ -23,5 +23,5 @@ Function Get-DownloadUrl { } $downloadUrl = Get-DownloadUrl -$outputFile = Join-Path -Path $PSScriptRoot -ChildPath "cobolcheck.exe" +$outputFile = Join-Path -Path "${HOME}" "cobolcheck" "cobolcheck.exe" Invoke-WebRequest -Uri $downloadUrl -OutFile $outputFile @requestOpts diff --git a/exercises/practice/anagram/test.ps1 b/exercises/practice/anagram/test.ps1 index b54fdc61..7a2bb33b 100644 --- a/exercises/practice/anagram/test.ps1 +++ b/exercises/practice/anagram/test.ps1 @@ -1,13 +1,11 @@ $slug=Split-Path $PSScriptRoot -Leaf -$cobolcheck = "$PSScriptRoot\bin\cobolcheck.exe" -$cobolcheckCmd = Get-Command "cobolcheck.exe" -ErrorAction SilentlyContinue +$cobolcheck = Join-Path -Path "${HOME}" "cobolcheck" "cobolcheck.exe" -if ($cobolcheckCmd) { - $cobolcheck = $cobolcheckCmd.Path - Write-Output "Found cobolcheck, using $cobolcheck" -} elseif (![System.IO.File]::Exists("$cobolcheck")){ +if (![System.IO.File]::Exists("$cobolcheck")){ + $fetchCobolcheckPath = Join-Path -Path "${PSScriptRoot}" "bin" "fetch-cobolcheck.ps1" + echo $fetchCobolcheckPath Write-Output "Cobolcheck not found. Trying to fetch it." - & "$PSScriptRoot\bin\fetch-cobolcheck.ps1" + & "${fetchCobolcheckPath}" } Write-Output "Run cobolcheck." diff --git a/exercises/practice/anagram/test.sh b/exercises/practice/anagram/test.sh old mode 100644 new mode 100755 index ed4a27a1..7b4a9da0 --- a/exercises/practice/anagram/test.sh +++ b/exercises/practice/anagram/test.sh @@ -1,13 +1,9 @@ #!/usr/bin/env bash SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )/ SLUG=${1:-$(basename "${SCRIPT_DIR}")} -COBOLCHECK=./bin/cobolcheck +COBOLCHECK="${HOME}/cobolcheck/cobolcheck" -WHICH_COBOLCHECK=$(which cobolcheck) -if [[ $? -eq 0 ]] ; then - echo "Found cobolcheck, using $COBOLCHECK" - COBOLCHECK=$WHICH_COBOLCHECK -elif [ ! -f $SCRIPT_DIR/bin/cobolcheck ]; then +if [ ! -f "${COBOLCHECK}" ]; then echo "Cobolcheck not found, try to fetch it." cd $SCRIPT_DIR/bin/ bash fetch-cobolcheck diff --git a/exercises/practice/armstrong-numbers/bin/fetch-cobolcheck b/exercises/practice/armstrong-numbers/bin/fetch-cobolcheck index 0b668734..b3d4adb1 100755 --- a/exercises/practice/armstrong-numbers/bin/fetch-cobolcheck +++ b/exercises/practice/armstrong-numbers/bin/fetch-cobolcheck @@ -45,19 +45,13 @@ 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_dir="${HOME}/cobolcheck" + mkdir -p "${output_dir}" output_path="${output_dir}/cobolcheck${ext}" download_url="$(get_download_url)" curl "${curlopts[@]}" --output "${output_path}" "${download_url}" chmod +x "${output_path}" + echo "Cobolcheck has been downloaded to ${output_path}" } main diff --git a/exercises/practice/armstrong-numbers/bin/fetch-cobolcheck.ps1 b/exercises/practice/armstrong-numbers/bin/fetch-cobolcheck.ps1 index a57f708d..9228452c 100644 --- a/exercises/practice/armstrong-numbers/bin/fetch-cobolcheck.ps1 +++ b/exercises/practice/armstrong-numbers/bin/fetch-cobolcheck.ps1 @@ -23,5 +23,5 @@ Function Get-DownloadUrl { } $downloadUrl = Get-DownloadUrl -$outputFile = Join-Path -Path $PSScriptRoot -ChildPath "cobolcheck.exe" +$outputFile = Join-Path -Path "${HOME}" "cobolcheck" "cobolcheck.exe" Invoke-WebRequest -Uri $downloadUrl -OutFile $outputFile @requestOpts diff --git a/exercises/practice/armstrong-numbers/test.ps1 b/exercises/practice/armstrong-numbers/test.ps1 index b54fdc61..7a2bb33b 100644 --- a/exercises/practice/armstrong-numbers/test.ps1 +++ b/exercises/practice/armstrong-numbers/test.ps1 @@ -1,13 +1,11 @@ $slug=Split-Path $PSScriptRoot -Leaf -$cobolcheck = "$PSScriptRoot\bin\cobolcheck.exe" -$cobolcheckCmd = Get-Command "cobolcheck.exe" -ErrorAction SilentlyContinue +$cobolcheck = Join-Path -Path "${HOME}" "cobolcheck" "cobolcheck.exe" -if ($cobolcheckCmd) { - $cobolcheck = $cobolcheckCmd.Path - Write-Output "Found cobolcheck, using $cobolcheck" -} elseif (![System.IO.File]::Exists("$cobolcheck")){ +if (![System.IO.File]::Exists("$cobolcheck")){ + $fetchCobolcheckPath = Join-Path -Path "${PSScriptRoot}" "bin" "fetch-cobolcheck.ps1" + echo $fetchCobolcheckPath Write-Output "Cobolcheck not found. Trying to fetch it." - & "$PSScriptRoot\bin\fetch-cobolcheck.ps1" + & "${fetchCobolcheckPath}" } Write-Output "Run cobolcheck." diff --git a/exercises/practice/armstrong-numbers/test.sh b/exercises/practice/armstrong-numbers/test.sh index ed4a27a1..7b4a9da0 100755 --- a/exercises/practice/armstrong-numbers/test.sh +++ b/exercises/practice/armstrong-numbers/test.sh @@ -1,13 +1,9 @@ #!/usr/bin/env bash SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )/ SLUG=${1:-$(basename "${SCRIPT_DIR}")} -COBOLCHECK=./bin/cobolcheck +COBOLCHECK="${HOME}/cobolcheck/cobolcheck" -WHICH_COBOLCHECK=$(which cobolcheck) -if [[ $? -eq 0 ]] ; then - echo "Found cobolcheck, using $COBOLCHECK" - COBOLCHECK=$WHICH_COBOLCHECK -elif [ ! -f $SCRIPT_DIR/bin/cobolcheck ]; then +if [ ! -f "${COBOLCHECK}" ]; then echo "Cobolcheck not found, try to fetch it." cd $SCRIPT_DIR/bin/ bash fetch-cobolcheck diff --git a/exercises/practice/atbash-cipher/bin/fetch-cobolcheck b/exercises/practice/atbash-cipher/bin/fetch-cobolcheck index 0b668734..b3d4adb1 100755 --- a/exercises/practice/atbash-cipher/bin/fetch-cobolcheck +++ b/exercises/practice/atbash-cipher/bin/fetch-cobolcheck @@ -45,19 +45,13 @@ 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_dir="${HOME}/cobolcheck" + mkdir -p "${output_dir}" output_path="${output_dir}/cobolcheck${ext}" download_url="$(get_download_url)" curl "${curlopts[@]}" --output "${output_path}" "${download_url}" chmod +x "${output_path}" + echo "Cobolcheck has been downloaded to ${output_path}" } main diff --git a/exercises/practice/atbash-cipher/bin/fetch-cobolcheck.ps1 b/exercises/practice/atbash-cipher/bin/fetch-cobolcheck.ps1 index a57f708d..9228452c 100644 --- a/exercises/practice/atbash-cipher/bin/fetch-cobolcheck.ps1 +++ b/exercises/practice/atbash-cipher/bin/fetch-cobolcheck.ps1 @@ -23,5 +23,5 @@ Function Get-DownloadUrl { } $downloadUrl = Get-DownloadUrl -$outputFile = Join-Path -Path $PSScriptRoot -ChildPath "cobolcheck.exe" +$outputFile = Join-Path -Path "${HOME}" "cobolcheck" "cobolcheck.exe" Invoke-WebRequest -Uri $downloadUrl -OutFile $outputFile @requestOpts diff --git a/exercises/practice/atbash-cipher/test.ps1 b/exercises/practice/atbash-cipher/test.ps1 index b54fdc61..7a2bb33b 100644 --- a/exercises/practice/atbash-cipher/test.ps1 +++ b/exercises/practice/atbash-cipher/test.ps1 @@ -1,13 +1,11 @@ $slug=Split-Path $PSScriptRoot -Leaf -$cobolcheck = "$PSScriptRoot\bin\cobolcheck.exe" -$cobolcheckCmd = Get-Command "cobolcheck.exe" -ErrorAction SilentlyContinue +$cobolcheck = Join-Path -Path "${HOME}" "cobolcheck" "cobolcheck.exe" -if ($cobolcheckCmd) { - $cobolcheck = $cobolcheckCmd.Path - Write-Output "Found cobolcheck, using $cobolcheck" -} elseif (![System.IO.File]::Exists("$cobolcheck")){ +if (![System.IO.File]::Exists("$cobolcheck")){ + $fetchCobolcheckPath = Join-Path -Path "${PSScriptRoot}" "bin" "fetch-cobolcheck.ps1" + echo $fetchCobolcheckPath Write-Output "Cobolcheck not found. Trying to fetch it." - & "$PSScriptRoot\bin\fetch-cobolcheck.ps1" + & "${fetchCobolcheckPath}" } Write-Output "Run cobolcheck." diff --git a/exercises/practice/atbash-cipher/test.sh b/exercises/practice/atbash-cipher/test.sh index ed4a27a1..7b4a9da0 100644 --- a/exercises/practice/atbash-cipher/test.sh +++ b/exercises/practice/atbash-cipher/test.sh @@ -1,13 +1,9 @@ #!/usr/bin/env bash SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )/ SLUG=${1:-$(basename "${SCRIPT_DIR}")} -COBOLCHECK=./bin/cobolcheck +COBOLCHECK="${HOME}/cobolcheck/cobolcheck" -WHICH_COBOLCHECK=$(which cobolcheck) -if [[ $? -eq 0 ]] ; then - echo "Found cobolcheck, using $COBOLCHECK" - COBOLCHECK=$WHICH_COBOLCHECK -elif [ ! -f $SCRIPT_DIR/bin/cobolcheck ]; then +if [ ! -f "${COBOLCHECK}" ]; then echo "Cobolcheck not found, try to fetch it." cd $SCRIPT_DIR/bin/ bash fetch-cobolcheck diff --git a/exercises/practice/binary-search/bin/fetch-cobolcheck b/exercises/practice/binary-search/bin/fetch-cobolcheck index 0b668734..b3d4adb1 100755 --- a/exercises/practice/binary-search/bin/fetch-cobolcheck +++ b/exercises/practice/binary-search/bin/fetch-cobolcheck @@ -45,19 +45,13 @@ 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_dir="${HOME}/cobolcheck" + mkdir -p "${output_dir}" output_path="${output_dir}/cobolcheck${ext}" download_url="$(get_download_url)" curl "${curlopts[@]}" --output "${output_path}" "${download_url}" chmod +x "${output_path}" + echo "Cobolcheck has been downloaded to ${output_path}" } main diff --git a/exercises/practice/binary-search/bin/fetch-cobolcheck.ps1 b/exercises/practice/binary-search/bin/fetch-cobolcheck.ps1 index a57f708d..9228452c 100644 --- a/exercises/practice/binary-search/bin/fetch-cobolcheck.ps1 +++ b/exercises/practice/binary-search/bin/fetch-cobolcheck.ps1 @@ -23,5 +23,5 @@ Function Get-DownloadUrl { } $downloadUrl = Get-DownloadUrl -$outputFile = Join-Path -Path $PSScriptRoot -ChildPath "cobolcheck.exe" +$outputFile = Join-Path -Path "${HOME}" "cobolcheck" "cobolcheck.exe" Invoke-WebRequest -Uri $downloadUrl -OutFile $outputFile @requestOpts diff --git a/exercises/practice/binary-search/test.ps1 b/exercises/practice/binary-search/test.ps1 index ccfa530a..7a2bb33b 100644 --- a/exercises/practice/binary-search/test.ps1 +++ b/exercises/practice/binary-search/test.ps1 @@ -1,14 +1,17 @@ $slug=Split-Path $PSScriptRoot -Leaf +$cobolcheck = Join-Path -Path "${HOME}" "cobolcheck" "cobolcheck.exe" -if (![System.IO.File]::Exists("$PSScriptRoot\bin\cobolcheck.exe")){ +if (![System.IO.File]::Exists("$cobolcheck")){ + $fetchCobolcheckPath = Join-Path -Path "${PSScriptRoot}" "bin" "fetch-cobolcheck.ps1" + echo $fetchCobolcheckPath Write-Output "Cobolcheck not found. Trying to fetch it." - & "$PSScriptRoot\bin\fetch-cobolcheck.ps1" + & "${fetchCobolcheckPath}" } Write-Output "Run cobolcheck." Set-Location $PSScriptRoot -Invoke-Expression "bin\cobolcheck.exe -p $slug" +Invoke-Expression "$cobolcheck -p $slug" Invoke-Expression "cobc -xj test.cob" if ($Lastexitcode -ne 0) { diff --git a/exercises/practice/binary-search/test.sh b/exercises/practice/binary-search/test.sh index ed4a27a1..7b4a9da0 100755 --- a/exercises/practice/binary-search/test.sh +++ b/exercises/practice/binary-search/test.sh @@ -1,13 +1,9 @@ #!/usr/bin/env bash SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )/ SLUG=${1:-$(basename "${SCRIPT_DIR}")} -COBOLCHECK=./bin/cobolcheck +COBOLCHECK="${HOME}/cobolcheck/cobolcheck" -WHICH_COBOLCHECK=$(which cobolcheck) -if [[ $? -eq 0 ]] ; then - echo "Found cobolcheck, using $COBOLCHECK" - COBOLCHECK=$WHICH_COBOLCHECK -elif [ ! -f $SCRIPT_DIR/bin/cobolcheck ]; then +if [ ! -f "${COBOLCHECK}" ]; then echo "Cobolcheck not found, try to fetch it." cd $SCRIPT_DIR/bin/ bash fetch-cobolcheck diff --git a/exercises/practice/binary/bin/fetch-cobolcheck b/exercises/practice/binary/bin/fetch-cobolcheck index 0b668734..b3d4adb1 100755 --- a/exercises/practice/binary/bin/fetch-cobolcheck +++ b/exercises/practice/binary/bin/fetch-cobolcheck @@ -45,19 +45,13 @@ 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_dir="${HOME}/cobolcheck" + mkdir -p "${output_dir}" output_path="${output_dir}/cobolcheck${ext}" download_url="$(get_download_url)" curl "${curlopts[@]}" --output "${output_path}" "${download_url}" chmod +x "${output_path}" + echo "Cobolcheck has been downloaded to ${output_path}" } main diff --git a/exercises/practice/binary/bin/fetch-cobolcheck.ps1 b/exercises/practice/binary/bin/fetch-cobolcheck.ps1 index a57f708d..9228452c 100644 --- a/exercises/practice/binary/bin/fetch-cobolcheck.ps1 +++ b/exercises/practice/binary/bin/fetch-cobolcheck.ps1 @@ -23,5 +23,5 @@ Function Get-DownloadUrl { } $downloadUrl = Get-DownloadUrl -$outputFile = Join-Path -Path $PSScriptRoot -ChildPath "cobolcheck.exe" +$outputFile = Join-Path -Path "${HOME}" "cobolcheck" "cobolcheck.exe" Invoke-WebRequest -Uri $downloadUrl -OutFile $outputFile @requestOpts diff --git a/exercises/practice/binary/test.ps1 b/exercises/practice/binary/test.ps1 index b54fdc61..7a2bb33b 100644 --- a/exercises/practice/binary/test.ps1 +++ b/exercises/practice/binary/test.ps1 @@ -1,13 +1,11 @@ $slug=Split-Path $PSScriptRoot -Leaf -$cobolcheck = "$PSScriptRoot\bin\cobolcheck.exe" -$cobolcheckCmd = Get-Command "cobolcheck.exe" -ErrorAction SilentlyContinue +$cobolcheck = Join-Path -Path "${HOME}" "cobolcheck" "cobolcheck.exe" -if ($cobolcheckCmd) { - $cobolcheck = $cobolcheckCmd.Path - Write-Output "Found cobolcheck, using $cobolcheck" -} elseif (![System.IO.File]::Exists("$cobolcheck")){ +if (![System.IO.File]::Exists("$cobolcheck")){ + $fetchCobolcheckPath = Join-Path -Path "${PSScriptRoot}" "bin" "fetch-cobolcheck.ps1" + echo $fetchCobolcheckPath Write-Output "Cobolcheck not found. Trying to fetch it." - & "$PSScriptRoot\bin\fetch-cobolcheck.ps1" + & "${fetchCobolcheckPath}" } Write-Output "Run cobolcheck." diff --git a/exercises/practice/binary/test.sh b/exercises/practice/binary/test.sh index ed4a27a1..7b4a9da0 100644 --- a/exercises/practice/binary/test.sh +++ b/exercises/practice/binary/test.sh @@ -1,13 +1,9 @@ #!/usr/bin/env bash SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )/ SLUG=${1:-$(basename "${SCRIPT_DIR}")} -COBOLCHECK=./bin/cobolcheck +COBOLCHECK="${HOME}/cobolcheck/cobolcheck" -WHICH_COBOLCHECK=$(which cobolcheck) -if [[ $? -eq 0 ]] ; then - echo "Found cobolcheck, using $COBOLCHECK" - COBOLCHECK=$WHICH_COBOLCHECK -elif [ ! -f $SCRIPT_DIR/bin/cobolcheck ]; then +if [ ! -f "${COBOLCHECK}" ]; then echo "Cobolcheck not found, try to fetch it." cd $SCRIPT_DIR/bin/ bash fetch-cobolcheck diff --git a/exercises/practice/bob/bin/fetch-cobolcheck b/exercises/practice/bob/bin/fetch-cobolcheck index 0b668734..b3d4adb1 100755 --- a/exercises/practice/bob/bin/fetch-cobolcheck +++ b/exercises/practice/bob/bin/fetch-cobolcheck @@ -45,19 +45,13 @@ 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_dir="${HOME}/cobolcheck" + mkdir -p "${output_dir}" output_path="${output_dir}/cobolcheck${ext}" download_url="$(get_download_url)" curl "${curlopts[@]}" --output "${output_path}" "${download_url}" chmod +x "${output_path}" + echo "Cobolcheck has been downloaded to ${output_path}" } main diff --git a/exercises/practice/bob/bin/fetch-cobolcheck.ps1 b/exercises/practice/bob/bin/fetch-cobolcheck.ps1 index a57f708d..9228452c 100644 --- a/exercises/practice/bob/bin/fetch-cobolcheck.ps1 +++ b/exercises/practice/bob/bin/fetch-cobolcheck.ps1 @@ -23,5 +23,5 @@ Function Get-DownloadUrl { } $downloadUrl = Get-DownloadUrl -$outputFile = Join-Path -Path $PSScriptRoot -ChildPath "cobolcheck.exe" +$outputFile = Join-Path -Path "${HOME}" "cobolcheck" "cobolcheck.exe" Invoke-WebRequest -Uri $downloadUrl -OutFile $outputFile @requestOpts diff --git a/exercises/practice/bob/test.ps1 b/exercises/practice/bob/test.ps1 index b54fdc61..7a2bb33b 100644 --- a/exercises/practice/bob/test.ps1 +++ b/exercises/practice/bob/test.ps1 @@ -1,13 +1,11 @@ $slug=Split-Path $PSScriptRoot -Leaf -$cobolcheck = "$PSScriptRoot\bin\cobolcheck.exe" -$cobolcheckCmd = Get-Command "cobolcheck.exe" -ErrorAction SilentlyContinue +$cobolcheck = Join-Path -Path "${HOME}" "cobolcheck" "cobolcheck.exe" -if ($cobolcheckCmd) { - $cobolcheck = $cobolcheckCmd.Path - Write-Output "Found cobolcheck, using $cobolcheck" -} elseif (![System.IO.File]::Exists("$cobolcheck")){ +if (![System.IO.File]::Exists("$cobolcheck")){ + $fetchCobolcheckPath = Join-Path -Path "${PSScriptRoot}" "bin" "fetch-cobolcheck.ps1" + echo $fetchCobolcheckPath Write-Output "Cobolcheck not found. Trying to fetch it." - & "$PSScriptRoot\bin\fetch-cobolcheck.ps1" + & "${fetchCobolcheckPath}" } Write-Output "Run cobolcheck." diff --git a/exercises/practice/bob/test.sh b/exercises/practice/bob/test.sh index ed4a27a1..7b4a9da0 100755 --- a/exercises/practice/bob/test.sh +++ b/exercises/practice/bob/test.sh @@ -1,13 +1,9 @@ #!/usr/bin/env bash SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )/ SLUG=${1:-$(basename "${SCRIPT_DIR}")} -COBOLCHECK=./bin/cobolcheck +COBOLCHECK="${HOME}/cobolcheck/cobolcheck" -WHICH_COBOLCHECK=$(which cobolcheck) -if [[ $? -eq 0 ]] ; then - echo "Found cobolcheck, using $COBOLCHECK" - COBOLCHECK=$WHICH_COBOLCHECK -elif [ ! -f $SCRIPT_DIR/bin/cobolcheck ]; then +if [ ! -f "${COBOLCHECK}" ]; then echo "Cobolcheck not found, try to fetch it." cd $SCRIPT_DIR/bin/ bash fetch-cobolcheck diff --git a/exercises/practice/circular-buffer/bin/fetch-cobolcheck b/exercises/practice/circular-buffer/bin/fetch-cobolcheck index 0b668734..b3d4adb1 100755 --- a/exercises/practice/circular-buffer/bin/fetch-cobolcheck +++ b/exercises/practice/circular-buffer/bin/fetch-cobolcheck @@ -45,19 +45,13 @@ 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_dir="${HOME}/cobolcheck" + mkdir -p "${output_dir}" output_path="${output_dir}/cobolcheck${ext}" download_url="$(get_download_url)" curl "${curlopts[@]}" --output "${output_path}" "${download_url}" chmod +x "${output_path}" + echo "Cobolcheck has been downloaded to ${output_path}" } main diff --git a/exercises/practice/circular-buffer/bin/fetch-cobolcheck.ps1 b/exercises/practice/circular-buffer/bin/fetch-cobolcheck.ps1 index a57f708d..9228452c 100644 --- a/exercises/practice/circular-buffer/bin/fetch-cobolcheck.ps1 +++ b/exercises/practice/circular-buffer/bin/fetch-cobolcheck.ps1 @@ -23,5 +23,5 @@ Function Get-DownloadUrl { } $downloadUrl = Get-DownloadUrl -$outputFile = Join-Path -Path $PSScriptRoot -ChildPath "cobolcheck.exe" +$outputFile = Join-Path -Path "${HOME}" "cobolcheck" "cobolcheck.exe" Invoke-WebRequest -Uri $downloadUrl -OutFile $outputFile @requestOpts diff --git a/exercises/practice/circular-buffer/test.ps1 b/exercises/practice/circular-buffer/test.ps1 index b54fdc61..7a2bb33b 100644 --- a/exercises/practice/circular-buffer/test.ps1 +++ b/exercises/practice/circular-buffer/test.ps1 @@ -1,13 +1,11 @@ $slug=Split-Path $PSScriptRoot -Leaf -$cobolcheck = "$PSScriptRoot\bin\cobolcheck.exe" -$cobolcheckCmd = Get-Command "cobolcheck.exe" -ErrorAction SilentlyContinue +$cobolcheck = Join-Path -Path "${HOME}" "cobolcheck" "cobolcheck.exe" -if ($cobolcheckCmd) { - $cobolcheck = $cobolcheckCmd.Path - Write-Output "Found cobolcheck, using $cobolcheck" -} elseif (![System.IO.File]::Exists("$cobolcheck")){ +if (![System.IO.File]::Exists("$cobolcheck")){ + $fetchCobolcheckPath = Join-Path -Path "${PSScriptRoot}" "bin" "fetch-cobolcheck.ps1" + echo $fetchCobolcheckPath Write-Output "Cobolcheck not found. Trying to fetch it." - & "$PSScriptRoot\bin\fetch-cobolcheck.ps1" + & "${fetchCobolcheckPath}" } Write-Output "Run cobolcheck." diff --git a/exercises/practice/circular-buffer/test.sh b/exercises/practice/circular-buffer/test.sh index ed4a27a1..7b4a9da0 100644 --- a/exercises/practice/circular-buffer/test.sh +++ b/exercises/practice/circular-buffer/test.sh @@ -1,13 +1,9 @@ #!/usr/bin/env bash SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )/ SLUG=${1:-$(basename "${SCRIPT_DIR}")} -COBOLCHECK=./bin/cobolcheck +COBOLCHECK="${HOME}/cobolcheck/cobolcheck" -WHICH_COBOLCHECK=$(which cobolcheck) -if [[ $? -eq 0 ]] ; then - echo "Found cobolcheck, using $COBOLCHECK" - COBOLCHECK=$WHICH_COBOLCHECK -elif [ ! -f $SCRIPT_DIR/bin/cobolcheck ]; then +if [ ! -f "${COBOLCHECK}" ]; then echo "Cobolcheck not found, try to fetch it." cd $SCRIPT_DIR/bin/ bash fetch-cobolcheck diff --git a/exercises/practice/collatz-conjecture/bin/fetch-cobolcheck b/exercises/practice/collatz-conjecture/bin/fetch-cobolcheck index 0b668734..b3d4adb1 100755 --- a/exercises/practice/collatz-conjecture/bin/fetch-cobolcheck +++ b/exercises/practice/collatz-conjecture/bin/fetch-cobolcheck @@ -45,19 +45,13 @@ 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_dir="${HOME}/cobolcheck" + mkdir -p "${output_dir}" output_path="${output_dir}/cobolcheck${ext}" download_url="$(get_download_url)" curl "${curlopts[@]}" --output "${output_path}" "${download_url}" chmod +x "${output_path}" + echo "Cobolcheck has been downloaded to ${output_path}" } main diff --git a/exercises/practice/collatz-conjecture/bin/fetch-cobolcheck.ps1 b/exercises/practice/collatz-conjecture/bin/fetch-cobolcheck.ps1 index a57f708d..9228452c 100644 --- a/exercises/practice/collatz-conjecture/bin/fetch-cobolcheck.ps1 +++ b/exercises/practice/collatz-conjecture/bin/fetch-cobolcheck.ps1 @@ -23,5 +23,5 @@ Function Get-DownloadUrl { } $downloadUrl = Get-DownloadUrl -$outputFile = Join-Path -Path $PSScriptRoot -ChildPath "cobolcheck.exe" +$outputFile = Join-Path -Path "${HOME}" "cobolcheck" "cobolcheck.exe" Invoke-WebRequest -Uri $downloadUrl -OutFile $outputFile @requestOpts diff --git a/exercises/practice/collatz-conjecture/test.ps1 b/exercises/practice/collatz-conjecture/test.ps1 index b54fdc61..7a2bb33b 100644 --- a/exercises/practice/collatz-conjecture/test.ps1 +++ b/exercises/practice/collatz-conjecture/test.ps1 @@ -1,13 +1,11 @@ $slug=Split-Path $PSScriptRoot -Leaf -$cobolcheck = "$PSScriptRoot\bin\cobolcheck.exe" -$cobolcheckCmd = Get-Command "cobolcheck.exe" -ErrorAction SilentlyContinue +$cobolcheck = Join-Path -Path "${HOME}" "cobolcheck" "cobolcheck.exe" -if ($cobolcheckCmd) { - $cobolcheck = $cobolcheckCmd.Path - Write-Output "Found cobolcheck, using $cobolcheck" -} elseif (![System.IO.File]::Exists("$cobolcheck")){ +if (![System.IO.File]::Exists("$cobolcheck")){ + $fetchCobolcheckPath = Join-Path -Path "${PSScriptRoot}" "bin" "fetch-cobolcheck.ps1" + echo $fetchCobolcheckPath Write-Output "Cobolcheck not found. Trying to fetch it." - & "$PSScriptRoot\bin\fetch-cobolcheck.ps1" + & "${fetchCobolcheckPath}" } Write-Output "Run cobolcheck." diff --git a/exercises/practice/collatz-conjecture/test.sh b/exercises/practice/collatz-conjecture/test.sh index ed4a27a1..7b4a9da0 100755 --- a/exercises/practice/collatz-conjecture/test.sh +++ b/exercises/practice/collatz-conjecture/test.sh @@ -1,13 +1,9 @@ #!/usr/bin/env bash SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )/ SLUG=${1:-$(basename "${SCRIPT_DIR}")} -COBOLCHECK=./bin/cobolcheck +COBOLCHECK="${HOME}/cobolcheck/cobolcheck" -WHICH_COBOLCHECK=$(which cobolcheck) -if [[ $? -eq 0 ]] ; then - echo "Found cobolcheck, using $COBOLCHECK" - COBOLCHECK=$WHICH_COBOLCHECK -elif [ ! -f $SCRIPT_DIR/bin/cobolcheck ]; then +if [ ! -f "${COBOLCHECK}" ]; then echo "Cobolcheck not found, try to fetch it." cd $SCRIPT_DIR/bin/ bash fetch-cobolcheck diff --git a/exercises/practice/complex-numbers/bin/fetch-cobolcheck b/exercises/practice/complex-numbers/bin/fetch-cobolcheck index 0b668734..b3d4adb1 100755 --- a/exercises/practice/complex-numbers/bin/fetch-cobolcheck +++ b/exercises/practice/complex-numbers/bin/fetch-cobolcheck @@ -45,19 +45,13 @@ 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_dir="${HOME}/cobolcheck" + mkdir -p "${output_dir}" output_path="${output_dir}/cobolcheck${ext}" download_url="$(get_download_url)" curl "${curlopts[@]}" --output "${output_path}" "${download_url}" chmod +x "${output_path}" + echo "Cobolcheck has been downloaded to ${output_path}" } main diff --git a/exercises/practice/complex-numbers/bin/fetch-cobolcheck.ps1 b/exercises/practice/complex-numbers/bin/fetch-cobolcheck.ps1 index a57f708d..9228452c 100644 --- a/exercises/practice/complex-numbers/bin/fetch-cobolcheck.ps1 +++ b/exercises/practice/complex-numbers/bin/fetch-cobolcheck.ps1 @@ -23,5 +23,5 @@ Function Get-DownloadUrl { } $downloadUrl = Get-DownloadUrl -$outputFile = Join-Path -Path $PSScriptRoot -ChildPath "cobolcheck.exe" +$outputFile = Join-Path -Path "${HOME}" "cobolcheck" "cobolcheck.exe" Invoke-WebRequest -Uri $downloadUrl -OutFile $outputFile @requestOpts diff --git a/exercises/practice/complex-numbers/test.ps1 b/exercises/practice/complex-numbers/test.ps1 index b54fdc61..7a2bb33b 100644 --- a/exercises/practice/complex-numbers/test.ps1 +++ b/exercises/practice/complex-numbers/test.ps1 @@ -1,13 +1,11 @@ $slug=Split-Path $PSScriptRoot -Leaf -$cobolcheck = "$PSScriptRoot\bin\cobolcheck.exe" -$cobolcheckCmd = Get-Command "cobolcheck.exe" -ErrorAction SilentlyContinue +$cobolcheck = Join-Path -Path "${HOME}" "cobolcheck" "cobolcheck.exe" -if ($cobolcheckCmd) { - $cobolcheck = $cobolcheckCmd.Path - Write-Output "Found cobolcheck, using $cobolcheck" -} elseif (![System.IO.File]::Exists("$cobolcheck")){ +if (![System.IO.File]::Exists("$cobolcheck")){ + $fetchCobolcheckPath = Join-Path -Path "${PSScriptRoot}" "bin" "fetch-cobolcheck.ps1" + echo $fetchCobolcheckPath Write-Output "Cobolcheck not found. Trying to fetch it." - & "$PSScriptRoot\bin\fetch-cobolcheck.ps1" + & "${fetchCobolcheckPath}" } Write-Output "Run cobolcheck." diff --git a/exercises/practice/complex-numbers/test.sh b/exercises/practice/complex-numbers/test.sh index ed4a27a1..7b4a9da0 100644 --- a/exercises/practice/complex-numbers/test.sh +++ b/exercises/practice/complex-numbers/test.sh @@ -1,13 +1,9 @@ #!/usr/bin/env bash SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )/ SLUG=${1:-$(basename "${SCRIPT_DIR}")} -COBOLCHECK=./bin/cobolcheck +COBOLCHECK="${HOME}/cobolcheck/cobolcheck" -WHICH_COBOLCHECK=$(which cobolcheck) -if [[ $? -eq 0 ]] ; then - echo "Found cobolcheck, using $COBOLCHECK" - COBOLCHECK=$WHICH_COBOLCHECK -elif [ ! -f $SCRIPT_DIR/bin/cobolcheck ]; then +if [ ! -f "${COBOLCHECK}" ]; then echo "Cobolcheck not found, try to fetch it." cd $SCRIPT_DIR/bin/ bash fetch-cobolcheck diff --git a/exercises/practice/darts/bin/fetch-cobolcheck b/exercises/practice/darts/bin/fetch-cobolcheck index 0b668734..b3d4adb1 100755 --- a/exercises/practice/darts/bin/fetch-cobolcheck +++ b/exercises/practice/darts/bin/fetch-cobolcheck @@ -45,19 +45,13 @@ 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_dir="${HOME}/cobolcheck" + mkdir -p "${output_dir}" output_path="${output_dir}/cobolcheck${ext}" download_url="$(get_download_url)" curl "${curlopts[@]}" --output "${output_path}" "${download_url}" chmod +x "${output_path}" + echo "Cobolcheck has been downloaded to ${output_path}" } main diff --git a/exercises/practice/darts/bin/fetch-cobolcheck.ps1 b/exercises/practice/darts/bin/fetch-cobolcheck.ps1 index a57f708d..9228452c 100644 --- a/exercises/practice/darts/bin/fetch-cobolcheck.ps1 +++ b/exercises/practice/darts/bin/fetch-cobolcheck.ps1 @@ -23,5 +23,5 @@ Function Get-DownloadUrl { } $downloadUrl = Get-DownloadUrl -$outputFile = Join-Path -Path $PSScriptRoot -ChildPath "cobolcheck.exe" +$outputFile = Join-Path -Path "${HOME}" "cobolcheck" "cobolcheck.exe" Invoke-WebRequest -Uri $downloadUrl -OutFile $outputFile @requestOpts diff --git a/exercises/practice/darts/test.ps1 b/exercises/practice/darts/test.ps1 index b54fdc61..7a2bb33b 100644 --- a/exercises/practice/darts/test.ps1 +++ b/exercises/practice/darts/test.ps1 @@ -1,13 +1,11 @@ $slug=Split-Path $PSScriptRoot -Leaf -$cobolcheck = "$PSScriptRoot\bin\cobolcheck.exe" -$cobolcheckCmd = Get-Command "cobolcheck.exe" -ErrorAction SilentlyContinue +$cobolcheck = Join-Path -Path "${HOME}" "cobolcheck" "cobolcheck.exe" -if ($cobolcheckCmd) { - $cobolcheck = $cobolcheckCmd.Path - Write-Output "Found cobolcheck, using $cobolcheck" -} elseif (![System.IO.File]::Exists("$cobolcheck")){ +if (![System.IO.File]::Exists("$cobolcheck")){ + $fetchCobolcheckPath = Join-Path -Path "${PSScriptRoot}" "bin" "fetch-cobolcheck.ps1" + echo $fetchCobolcheckPath Write-Output "Cobolcheck not found. Trying to fetch it." - & "$PSScriptRoot\bin\fetch-cobolcheck.ps1" + & "${fetchCobolcheckPath}" } Write-Output "Run cobolcheck." diff --git a/exercises/practice/darts/test.sh b/exercises/practice/darts/test.sh index ed4a27a1..7b4a9da0 100755 --- a/exercises/practice/darts/test.sh +++ b/exercises/practice/darts/test.sh @@ -1,13 +1,9 @@ #!/usr/bin/env bash SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )/ SLUG=${1:-$(basename "${SCRIPT_DIR}")} -COBOLCHECK=./bin/cobolcheck +COBOLCHECK="${HOME}/cobolcheck/cobolcheck" -WHICH_COBOLCHECK=$(which cobolcheck) -if [[ $? -eq 0 ]] ; then - echo "Found cobolcheck, using $COBOLCHECK" - COBOLCHECK=$WHICH_COBOLCHECK -elif [ ! -f $SCRIPT_DIR/bin/cobolcheck ]; then +if [ ! -f "${COBOLCHECK}" ]; then echo "Cobolcheck not found, try to fetch it." cd $SCRIPT_DIR/bin/ bash fetch-cobolcheck diff --git a/exercises/practice/diamond/bin/fetch-cobolcheck b/exercises/practice/diamond/bin/fetch-cobolcheck index 0b668734..b3d4adb1 100755 --- a/exercises/practice/diamond/bin/fetch-cobolcheck +++ b/exercises/practice/diamond/bin/fetch-cobolcheck @@ -45,19 +45,13 @@ 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_dir="${HOME}/cobolcheck" + mkdir -p "${output_dir}" output_path="${output_dir}/cobolcheck${ext}" download_url="$(get_download_url)" curl "${curlopts[@]}" --output "${output_path}" "${download_url}" chmod +x "${output_path}" + echo "Cobolcheck has been downloaded to ${output_path}" } main diff --git a/exercises/practice/diamond/bin/fetch-cobolcheck.ps1 b/exercises/practice/diamond/bin/fetch-cobolcheck.ps1 index a57f708d..9228452c 100644 --- a/exercises/practice/diamond/bin/fetch-cobolcheck.ps1 +++ b/exercises/practice/diamond/bin/fetch-cobolcheck.ps1 @@ -23,5 +23,5 @@ Function Get-DownloadUrl { } $downloadUrl = Get-DownloadUrl -$outputFile = Join-Path -Path $PSScriptRoot -ChildPath "cobolcheck.exe" +$outputFile = Join-Path -Path "${HOME}" "cobolcheck" "cobolcheck.exe" Invoke-WebRequest -Uri $downloadUrl -OutFile $outputFile @requestOpts diff --git a/exercises/practice/diamond/test.ps1 b/exercises/practice/diamond/test.ps1 index b54fdc61..7a2bb33b 100644 --- a/exercises/practice/diamond/test.ps1 +++ b/exercises/practice/diamond/test.ps1 @@ -1,13 +1,11 @@ $slug=Split-Path $PSScriptRoot -Leaf -$cobolcheck = "$PSScriptRoot\bin\cobolcheck.exe" -$cobolcheckCmd = Get-Command "cobolcheck.exe" -ErrorAction SilentlyContinue +$cobolcheck = Join-Path -Path "${HOME}" "cobolcheck" "cobolcheck.exe" -if ($cobolcheckCmd) { - $cobolcheck = $cobolcheckCmd.Path - Write-Output "Found cobolcheck, using $cobolcheck" -} elseif (![System.IO.File]::Exists("$cobolcheck")){ +if (![System.IO.File]::Exists("$cobolcheck")){ + $fetchCobolcheckPath = Join-Path -Path "${PSScriptRoot}" "bin" "fetch-cobolcheck.ps1" + echo $fetchCobolcheckPath Write-Output "Cobolcheck not found. Trying to fetch it." - & "$PSScriptRoot\bin\fetch-cobolcheck.ps1" + & "${fetchCobolcheckPath}" } Write-Output "Run cobolcheck." diff --git a/exercises/practice/diamond/test.sh b/exercises/practice/diamond/test.sh index ed4a27a1..7b4a9da0 100755 --- a/exercises/practice/diamond/test.sh +++ b/exercises/practice/diamond/test.sh @@ -1,13 +1,9 @@ #!/usr/bin/env bash SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )/ SLUG=${1:-$(basename "${SCRIPT_DIR}")} -COBOLCHECK=./bin/cobolcheck +COBOLCHECK="${HOME}/cobolcheck/cobolcheck" -WHICH_COBOLCHECK=$(which cobolcheck) -if [[ $? -eq 0 ]] ; then - echo "Found cobolcheck, using $COBOLCHECK" - COBOLCHECK=$WHICH_COBOLCHECK -elif [ ! -f $SCRIPT_DIR/bin/cobolcheck ]; then +if [ ! -f "${COBOLCHECK}" ]; then echo "Cobolcheck not found, try to fetch it." cd $SCRIPT_DIR/bin/ bash fetch-cobolcheck diff --git a/exercises/practice/difference-of-squares/bin/fetch-cobolcheck b/exercises/practice/difference-of-squares/bin/fetch-cobolcheck index 0b668734..b3d4adb1 100755 --- a/exercises/practice/difference-of-squares/bin/fetch-cobolcheck +++ b/exercises/practice/difference-of-squares/bin/fetch-cobolcheck @@ -45,19 +45,13 @@ 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_dir="${HOME}/cobolcheck" + mkdir -p "${output_dir}" output_path="${output_dir}/cobolcheck${ext}" download_url="$(get_download_url)" curl "${curlopts[@]}" --output "${output_path}" "${download_url}" chmod +x "${output_path}" + echo "Cobolcheck has been downloaded to ${output_path}" } main diff --git a/exercises/practice/difference-of-squares/bin/fetch-cobolcheck.ps1 b/exercises/practice/difference-of-squares/bin/fetch-cobolcheck.ps1 index a57f708d..9228452c 100644 --- a/exercises/practice/difference-of-squares/bin/fetch-cobolcheck.ps1 +++ b/exercises/practice/difference-of-squares/bin/fetch-cobolcheck.ps1 @@ -23,5 +23,5 @@ Function Get-DownloadUrl { } $downloadUrl = Get-DownloadUrl -$outputFile = Join-Path -Path $PSScriptRoot -ChildPath "cobolcheck.exe" +$outputFile = Join-Path -Path "${HOME}" "cobolcheck" "cobolcheck.exe" Invoke-WebRequest -Uri $downloadUrl -OutFile $outputFile @requestOpts diff --git a/exercises/practice/difference-of-squares/test.ps1 b/exercises/practice/difference-of-squares/test.ps1 index b54fdc61..7a2bb33b 100644 --- a/exercises/practice/difference-of-squares/test.ps1 +++ b/exercises/practice/difference-of-squares/test.ps1 @@ -1,13 +1,11 @@ $slug=Split-Path $PSScriptRoot -Leaf -$cobolcheck = "$PSScriptRoot\bin\cobolcheck.exe" -$cobolcheckCmd = Get-Command "cobolcheck.exe" -ErrorAction SilentlyContinue +$cobolcheck = Join-Path -Path "${HOME}" "cobolcheck" "cobolcheck.exe" -if ($cobolcheckCmd) { - $cobolcheck = $cobolcheckCmd.Path - Write-Output "Found cobolcheck, using $cobolcheck" -} elseif (![System.IO.File]::Exists("$cobolcheck")){ +if (![System.IO.File]::Exists("$cobolcheck")){ + $fetchCobolcheckPath = Join-Path -Path "${PSScriptRoot}" "bin" "fetch-cobolcheck.ps1" + echo $fetchCobolcheckPath Write-Output "Cobolcheck not found. Trying to fetch it." - & "$PSScriptRoot\bin\fetch-cobolcheck.ps1" + & "${fetchCobolcheckPath}" } Write-Output "Run cobolcheck." diff --git a/exercises/practice/difference-of-squares/test.sh b/exercises/practice/difference-of-squares/test.sh index ed4a27a1..7b4a9da0 100755 --- a/exercises/practice/difference-of-squares/test.sh +++ b/exercises/practice/difference-of-squares/test.sh @@ -1,13 +1,9 @@ #!/usr/bin/env bash SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )/ SLUG=${1:-$(basename "${SCRIPT_DIR}")} -COBOLCHECK=./bin/cobolcheck +COBOLCHECK="${HOME}/cobolcheck/cobolcheck" -WHICH_COBOLCHECK=$(which cobolcheck) -if [[ $? -eq 0 ]] ; then - echo "Found cobolcheck, using $COBOLCHECK" - COBOLCHECK=$WHICH_COBOLCHECK -elif [ ! -f $SCRIPT_DIR/bin/cobolcheck ]; then +if [ ! -f "${COBOLCHECK}" ]; then echo "Cobolcheck not found, try to fetch it." cd $SCRIPT_DIR/bin/ bash fetch-cobolcheck diff --git a/exercises/practice/eliuds-eggs/bin/fetch-cobolcheck b/exercises/practice/eliuds-eggs/bin/fetch-cobolcheck index 0b668734..b3d4adb1 100755 --- a/exercises/practice/eliuds-eggs/bin/fetch-cobolcheck +++ b/exercises/practice/eliuds-eggs/bin/fetch-cobolcheck @@ -45,19 +45,13 @@ 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_dir="${HOME}/cobolcheck" + mkdir -p "${output_dir}" output_path="${output_dir}/cobolcheck${ext}" download_url="$(get_download_url)" curl "${curlopts[@]}" --output "${output_path}" "${download_url}" chmod +x "${output_path}" + echo "Cobolcheck has been downloaded to ${output_path}" } main diff --git a/exercises/practice/eliuds-eggs/bin/fetch-cobolcheck.ps1 b/exercises/practice/eliuds-eggs/bin/fetch-cobolcheck.ps1 index a57f708d..9228452c 100644 --- a/exercises/practice/eliuds-eggs/bin/fetch-cobolcheck.ps1 +++ b/exercises/practice/eliuds-eggs/bin/fetch-cobolcheck.ps1 @@ -23,5 +23,5 @@ Function Get-DownloadUrl { } $downloadUrl = Get-DownloadUrl -$outputFile = Join-Path -Path $PSScriptRoot -ChildPath "cobolcheck.exe" +$outputFile = Join-Path -Path "${HOME}" "cobolcheck" "cobolcheck.exe" Invoke-WebRequest -Uri $downloadUrl -OutFile $outputFile @requestOpts diff --git a/exercises/practice/eliuds-eggs/test.ps1 b/exercises/practice/eliuds-eggs/test.ps1 index b54fdc61..7a2bb33b 100644 --- a/exercises/practice/eliuds-eggs/test.ps1 +++ b/exercises/practice/eliuds-eggs/test.ps1 @@ -1,13 +1,11 @@ $slug=Split-Path $PSScriptRoot -Leaf -$cobolcheck = "$PSScriptRoot\bin\cobolcheck.exe" -$cobolcheckCmd = Get-Command "cobolcheck.exe" -ErrorAction SilentlyContinue +$cobolcheck = Join-Path -Path "${HOME}" "cobolcheck" "cobolcheck.exe" -if ($cobolcheckCmd) { - $cobolcheck = $cobolcheckCmd.Path - Write-Output "Found cobolcheck, using $cobolcheck" -} elseif (![System.IO.File]::Exists("$cobolcheck")){ +if (![System.IO.File]::Exists("$cobolcheck")){ + $fetchCobolcheckPath = Join-Path -Path "${PSScriptRoot}" "bin" "fetch-cobolcheck.ps1" + echo $fetchCobolcheckPath Write-Output "Cobolcheck not found. Trying to fetch it." - & "$PSScriptRoot\bin\fetch-cobolcheck.ps1" + & "${fetchCobolcheckPath}" } Write-Output "Run cobolcheck." diff --git a/exercises/practice/eliuds-eggs/test.sh b/exercises/practice/eliuds-eggs/test.sh index ed4a27a1..7b4a9da0 100755 --- a/exercises/practice/eliuds-eggs/test.sh +++ b/exercises/practice/eliuds-eggs/test.sh @@ -1,13 +1,9 @@ #!/usr/bin/env bash SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )/ SLUG=${1:-$(basename "${SCRIPT_DIR}")} -COBOLCHECK=./bin/cobolcheck +COBOLCHECK="${HOME}/cobolcheck/cobolcheck" -WHICH_COBOLCHECK=$(which cobolcheck) -if [[ $? -eq 0 ]] ; then - echo "Found cobolcheck, using $COBOLCHECK" - COBOLCHECK=$WHICH_COBOLCHECK -elif [ ! -f $SCRIPT_DIR/bin/cobolcheck ]; then +if [ ! -f "${COBOLCHECK}" ]; then echo "Cobolcheck not found, try to fetch it." cd $SCRIPT_DIR/bin/ bash fetch-cobolcheck diff --git a/exercises/practice/grade-school/bin/fetch-cobolcheck b/exercises/practice/grade-school/bin/fetch-cobolcheck index 0b668734..b3d4adb1 100755 --- a/exercises/practice/grade-school/bin/fetch-cobolcheck +++ b/exercises/practice/grade-school/bin/fetch-cobolcheck @@ -45,19 +45,13 @@ 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_dir="${HOME}/cobolcheck" + mkdir -p "${output_dir}" output_path="${output_dir}/cobolcheck${ext}" download_url="$(get_download_url)" curl "${curlopts[@]}" --output "${output_path}" "${download_url}" chmod +x "${output_path}" + echo "Cobolcheck has been downloaded to ${output_path}" } main diff --git a/exercises/practice/grade-school/bin/fetch-cobolcheck.ps1 b/exercises/practice/grade-school/bin/fetch-cobolcheck.ps1 index a57f708d..9228452c 100644 --- a/exercises/practice/grade-school/bin/fetch-cobolcheck.ps1 +++ b/exercises/practice/grade-school/bin/fetch-cobolcheck.ps1 @@ -23,5 +23,5 @@ Function Get-DownloadUrl { } $downloadUrl = Get-DownloadUrl -$outputFile = Join-Path -Path $PSScriptRoot -ChildPath "cobolcheck.exe" +$outputFile = Join-Path -Path "${HOME}" "cobolcheck" "cobolcheck.exe" Invoke-WebRequest -Uri $downloadUrl -OutFile $outputFile @requestOpts diff --git a/exercises/practice/grade-school/test.ps1 b/exercises/practice/grade-school/test.ps1 index b54fdc61..7a2bb33b 100644 --- a/exercises/practice/grade-school/test.ps1 +++ b/exercises/practice/grade-school/test.ps1 @@ -1,13 +1,11 @@ $slug=Split-Path $PSScriptRoot -Leaf -$cobolcheck = "$PSScriptRoot\bin\cobolcheck.exe" -$cobolcheckCmd = Get-Command "cobolcheck.exe" -ErrorAction SilentlyContinue +$cobolcheck = Join-Path -Path "${HOME}" "cobolcheck" "cobolcheck.exe" -if ($cobolcheckCmd) { - $cobolcheck = $cobolcheckCmd.Path - Write-Output "Found cobolcheck, using $cobolcheck" -} elseif (![System.IO.File]::Exists("$cobolcheck")){ +if (![System.IO.File]::Exists("$cobolcheck")){ + $fetchCobolcheckPath = Join-Path -Path "${PSScriptRoot}" "bin" "fetch-cobolcheck.ps1" + echo $fetchCobolcheckPath Write-Output "Cobolcheck not found. Trying to fetch it." - & "$PSScriptRoot\bin\fetch-cobolcheck.ps1" + & "${fetchCobolcheckPath}" } Write-Output "Run cobolcheck." diff --git a/exercises/practice/grade-school/test.sh b/exercises/practice/grade-school/test.sh index ed4a27a1..7b4a9da0 100755 --- a/exercises/practice/grade-school/test.sh +++ b/exercises/practice/grade-school/test.sh @@ -1,13 +1,9 @@ #!/usr/bin/env bash SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )/ SLUG=${1:-$(basename "${SCRIPT_DIR}")} -COBOLCHECK=./bin/cobolcheck +COBOLCHECK="${HOME}/cobolcheck/cobolcheck" -WHICH_COBOLCHECK=$(which cobolcheck) -if [[ $? -eq 0 ]] ; then - echo "Found cobolcheck, using $COBOLCHECK" - COBOLCHECK=$WHICH_COBOLCHECK -elif [ ! -f $SCRIPT_DIR/bin/cobolcheck ]; then +if [ ! -f "${COBOLCHECK}" ]; then echo "Cobolcheck not found, try to fetch it." cd $SCRIPT_DIR/bin/ bash fetch-cobolcheck diff --git a/exercises/practice/hamming/bin/fetch-cobolcheck b/exercises/practice/hamming/bin/fetch-cobolcheck index 0b668734..b3d4adb1 100755 --- a/exercises/practice/hamming/bin/fetch-cobolcheck +++ b/exercises/practice/hamming/bin/fetch-cobolcheck @@ -45,19 +45,13 @@ 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_dir="${HOME}/cobolcheck" + mkdir -p "${output_dir}" output_path="${output_dir}/cobolcheck${ext}" download_url="$(get_download_url)" curl "${curlopts[@]}" --output "${output_path}" "${download_url}" chmod +x "${output_path}" + echo "Cobolcheck has been downloaded to ${output_path}" } main diff --git a/exercises/practice/hamming/bin/fetch-cobolcheck.ps1 b/exercises/practice/hamming/bin/fetch-cobolcheck.ps1 index a57f708d..9228452c 100644 --- a/exercises/practice/hamming/bin/fetch-cobolcheck.ps1 +++ b/exercises/practice/hamming/bin/fetch-cobolcheck.ps1 @@ -23,5 +23,5 @@ Function Get-DownloadUrl { } $downloadUrl = Get-DownloadUrl -$outputFile = Join-Path -Path $PSScriptRoot -ChildPath "cobolcheck.exe" +$outputFile = Join-Path -Path "${HOME}" "cobolcheck" "cobolcheck.exe" Invoke-WebRequest -Uri $downloadUrl -OutFile $outputFile @requestOpts diff --git a/exercises/practice/hamming/test.ps1 b/exercises/practice/hamming/test.ps1 index b54fdc61..7a2bb33b 100644 --- a/exercises/practice/hamming/test.ps1 +++ b/exercises/practice/hamming/test.ps1 @@ -1,13 +1,11 @@ $slug=Split-Path $PSScriptRoot -Leaf -$cobolcheck = "$PSScriptRoot\bin\cobolcheck.exe" -$cobolcheckCmd = Get-Command "cobolcheck.exe" -ErrorAction SilentlyContinue +$cobolcheck = Join-Path -Path "${HOME}" "cobolcheck" "cobolcheck.exe" -if ($cobolcheckCmd) { - $cobolcheck = $cobolcheckCmd.Path - Write-Output "Found cobolcheck, using $cobolcheck" -} elseif (![System.IO.File]::Exists("$cobolcheck")){ +if (![System.IO.File]::Exists("$cobolcheck")){ + $fetchCobolcheckPath = Join-Path -Path "${PSScriptRoot}" "bin" "fetch-cobolcheck.ps1" + echo $fetchCobolcheckPath Write-Output "Cobolcheck not found. Trying to fetch it." - & "$PSScriptRoot\bin\fetch-cobolcheck.ps1" + & "${fetchCobolcheckPath}" } Write-Output "Run cobolcheck." diff --git a/exercises/practice/hamming/test.sh b/exercises/practice/hamming/test.sh index 8bb4caa3..7b4a9da0 100755 --- a/exercises/practice/hamming/test.sh +++ b/exercises/practice/hamming/test.sh @@ -1,13 +1,9 @@ #!/usr/bin/env bash SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )/ SLUG=${1:-$(basename "${SCRIPT_DIR}")} -COBOLCHECK=./bin/cobolcheck +COBOLCHECK="${HOME}/cobolcheck/cobolcheck" -WHICH_COBOLCHECK=$(which cobolcheck) -if [[ $? -eq 0 ]] ; then - echo "Found cobolcheck, using $COBOLCHECK" - COBOLCHECK=$WHICH_COBOLCHECK -elif [ ! -f $SCRIPT_DIR/bin/cobolcheck ]; then +if [ ! -f "${COBOLCHECK}" ]; then echo "Cobolcheck not found, try to fetch it." cd $SCRIPT_DIR/bin/ bash fetch-cobolcheck @@ -18,4 +14,3 @@ $COBOLCHECK -p $SLUG # compile and run echo "COMPILE AND RUN TEST" cobc -xj test.cob - diff --git a/exercises/practice/hello-world/bin/fetch-cobolcheck b/exercises/practice/hello-world/bin/fetch-cobolcheck index 0b668734..b3d4adb1 100755 --- a/exercises/practice/hello-world/bin/fetch-cobolcheck +++ b/exercises/practice/hello-world/bin/fetch-cobolcheck @@ -45,19 +45,13 @@ 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_dir="${HOME}/cobolcheck" + mkdir -p "${output_dir}" output_path="${output_dir}/cobolcheck${ext}" download_url="$(get_download_url)" curl "${curlopts[@]}" --output "${output_path}" "${download_url}" chmod +x "${output_path}" + echo "Cobolcheck has been downloaded to ${output_path}" } main diff --git a/exercises/practice/hello-world/bin/fetch-cobolcheck.ps1 b/exercises/practice/hello-world/bin/fetch-cobolcheck.ps1 index a57f708d..9228452c 100644 --- a/exercises/practice/hello-world/bin/fetch-cobolcheck.ps1 +++ b/exercises/practice/hello-world/bin/fetch-cobolcheck.ps1 @@ -23,5 +23,5 @@ Function Get-DownloadUrl { } $downloadUrl = Get-DownloadUrl -$outputFile = Join-Path -Path $PSScriptRoot -ChildPath "cobolcheck.exe" +$outputFile = Join-Path -Path "${HOME}" "cobolcheck" "cobolcheck.exe" Invoke-WebRequest -Uri $downloadUrl -OutFile $outputFile @requestOpts diff --git a/exercises/practice/hello-world/test.ps1 b/exercises/practice/hello-world/test.ps1 index b54fdc61..7a2bb33b 100644 --- a/exercises/practice/hello-world/test.ps1 +++ b/exercises/practice/hello-world/test.ps1 @@ -1,13 +1,11 @@ $slug=Split-Path $PSScriptRoot -Leaf -$cobolcheck = "$PSScriptRoot\bin\cobolcheck.exe" -$cobolcheckCmd = Get-Command "cobolcheck.exe" -ErrorAction SilentlyContinue +$cobolcheck = Join-Path -Path "${HOME}" "cobolcheck" "cobolcheck.exe" -if ($cobolcheckCmd) { - $cobolcheck = $cobolcheckCmd.Path - Write-Output "Found cobolcheck, using $cobolcheck" -} elseif (![System.IO.File]::Exists("$cobolcheck")){ +if (![System.IO.File]::Exists("$cobolcheck")){ + $fetchCobolcheckPath = Join-Path -Path "${PSScriptRoot}" "bin" "fetch-cobolcheck.ps1" + echo $fetchCobolcheckPath Write-Output "Cobolcheck not found. Trying to fetch it." - & "$PSScriptRoot\bin\fetch-cobolcheck.ps1" + & "${fetchCobolcheckPath}" } Write-Output "Run cobolcheck." diff --git a/exercises/practice/hello-world/test.sh b/exercises/practice/hello-world/test.sh index ed4a27a1..7b4a9da0 100755 --- a/exercises/practice/hello-world/test.sh +++ b/exercises/practice/hello-world/test.sh @@ -1,13 +1,9 @@ #!/usr/bin/env bash SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )/ SLUG=${1:-$(basename "${SCRIPT_DIR}")} -COBOLCHECK=./bin/cobolcheck +COBOLCHECK="${HOME}/cobolcheck/cobolcheck" -WHICH_COBOLCHECK=$(which cobolcheck) -if [[ $? -eq 0 ]] ; then - echo "Found cobolcheck, using $COBOLCHECK" - COBOLCHECK=$WHICH_COBOLCHECK -elif [ ! -f $SCRIPT_DIR/bin/cobolcheck ]; then +if [ ! -f "${COBOLCHECK}" ]; then echo "Cobolcheck not found, try to fetch it." cd $SCRIPT_DIR/bin/ bash fetch-cobolcheck diff --git a/exercises/practice/high-scores/bin/fetch-cobolcheck b/exercises/practice/high-scores/bin/fetch-cobolcheck index 0b668734..b3d4adb1 100755 --- a/exercises/practice/high-scores/bin/fetch-cobolcheck +++ b/exercises/practice/high-scores/bin/fetch-cobolcheck @@ -45,19 +45,13 @@ 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_dir="${HOME}/cobolcheck" + mkdir -p "${output_dir}" output_path="${output_dir}/cobolcheck${ext}" download_url="$(get_download_url)" curl "${curlopts[@]}" --output "${output_path}" "${download_url}" chmod +x "${output_path}" + echo "Cobolcheck has been downloaded to ${output_path}" } main diff --git a/exercises/practice/high-scores/bin/fetch-cobolcheck.ps1 b/exercises/practice/high-scores/bin/fetch-cobolcheck.ps1 index a57f708d..9228452c 100644 --- a/exercises/practice/high-scores/bin/fetch-cobolcheck.ps1 +++ b/exercises/practice/high-scores/bin/fetch-cobolcheck.ps1 @@ -23,5 +23,5 @@ Function Get-DownloadUrl { } $downloadUrl = Get-DownloadUrl -$outputFile = Join-Path -Path $PSScriptRoot -ChildPath "cobolcheck.exe" +$outputFile = Join-Path -Path "${HOME}" "cobolcheck" "cobolcheck.exe" Invoke-WebRequest -Uri $downloadUrl -OutFile $outputFile @requestOpts diff --git a/exercises/practice/high-scores/test.ps1 b/exercises/practice/high-scores/test.ps1 index b54fdc61..7a2bb33b 100644 --- a/exercises/practice/high-scores/test.ps1 +++ b/exercises/practice/high-scores/test.ps1 @@ -1,13 +1,11 @@ $slug=Split-Path $PSScriptRoot -Leaf -$cobolcheck = "$PSScriptRoot\bin\cobolcheck.exe" -$cobolcheckCmd = Get-Command "cobolcheck.exe" -ErrorAction SilentlyContinue +$cobolcheck = Join-Path -Path "${HOME}" "cobolcheck" "cobolcheck.exe" -if ($cobolcheckCmd) { - $cobolcheck = $cobolcheckCmd.Path - Write-Output "Found cobolcheck, using $cobolcheck" -} elseif (![System.IO.File]::Exists("$cobolcheck")){ +if (![System.IO.File]::Exists("$cobolcheck")){ + $fetchCobolcheckPath = Join-Path -Path "${PSScriptRoot}" "bin" "fetch-cobolcheck.ps1" + echo $fetchCobolcheckPath Write-Output "Cobolcheck not found. Trying to fetch it." - & "$PSScriptRoot\bin\fetch-cobolcheck.ps1" + & "${fetchCobolcheckPath}" } Write-Output "Run cobolcheck." diff --git a/exercises/practice/high-scores/test.sh b/exercises/practice/high-scores/test.sh index ed4a27a1..7b4a9da0 100644 --- a/exercises/practice/high-scores/test.sh +++ b/exercises/practice/high-scores/test.sh @@ -1,13 +1,9 @@ #!/usr/bin/env bash SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )/ SLUG=${1:-$(basename "${SCRIPT_DIR}")} -COBOLCHECK=./bin/cobolcheck +COBOLCHECK="${HOME}/cobolcheck/cobolcheck" -WHICH_COBOLCHECK=$(which cobolcheck) -if [[ $? -eq 0 ]] ; then - echo "Found cobolcheck, using $COBOLCHECK" - COBOLCHECK=$WHICH_COBOLCHECK -elif [ ! -f $SCRIPT_DIR/bin/cobolcheck ]; then +if [ ! -f "${COBOLCHECK}" ]; then echo "Cobolcheck not found, try to fetch it." cd $SCRIPT_DIR/bin/ bash fetch-cobolcheck diff --git a/exercises/practice/isogram/bin/fetch-cobolcheck b/exercises/practice/isogram/bin/fetch-cobolcheck index 0b668734..b3d4adb1 100755 --- a/exercises/practice/isogram/bin/fetch-cobolcheck +++ b/exercises/practice/isogram/bin/fetch-cobolcheck @@ -45,19 +45,13 @@ 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_dir="${HOME}/cobolcheck" + mkdir -p "${output_dir}" output_path="${output_dir}/cobolcheck${ext}" download_url="$(get_download_url)" curl "${curlopts[@]}" --output "${output_path}" "${download_url}" chmod +x "${output_path}" + echo "Cobolcheck has been downloaded to ${output_path}" } main diff --git a/exercises/practice/isogram/bin/fetch-cobolcheck.ps1 b/exercises/practice/isogram/bin/fetch-cobolcheck.ps1 index a57f708d..9228452c 100644 --- a/exercises/practice/isogram/bin/fetch-cobolcheck.ps1 +++ b/exercises/practice/isogram/bin/fetch-cobolcheck.ps1 @@ -23,5 +23,5 @@ Function Get-DownloadUrl { } $downloadUrl = Get-DownloadUrl -$outputFile = Join-Path -Path $PSScriptRoot -ChildPath "cobolcheck.exe" +$outputFile = Join-Path -Path "${HOME}" "cobolcheck" "cobolcheck.exe" Invoke-WebRequest -Uri $downloadUrl -OutFile $outputFile @requestOpts diff --git a/exercises/practice/isogram/test.ps1 b/exercises/practice/isogram/test.ps1 index b54fdc61..7a2bb33b 100644 --- a/exercises/practice/isogram/test.ps1 +++ b/exercises/practice/isogram/test.ps1 @@ -1,13 +1,11 @@ $slug=Split-Path $PSScriptRoot -Leaf -$cobolcheck = "$PSScriptRoot\bin\cobolcheck.exe" -$cobolcheckCmd = Get-Command "cobolcheck.exe" -ErrorAction SilentlyContinue +$cobolcheck = Join-Path -Path "${HOME}" "cobolcheck" "cobolcheck.exe" -if ($cobolcheckCmd) { - $cobolcheck = $cobolcheckCmd.Path - Write-Output "Found cobolcheck, using $cobolcheck" -} elseif (![System.IO.File]::Exists("$cobolcheck")){ +if (![System.IO.File]::Exists("$cobolcheck")){ + $fetchCobolcheckPath = Join-Path -Path "${PSScriptRoot}" "bin" "fetch-cobolcheck.ps1" + echo $fetchCobolcheckPath Write-Output "Cobolcheck not found. Trying to fetch it." - & "$PSScriptRoot\bin\fetch-cobolcheck.ps1" + & "${fetchCobolcheckPath}" } Write-Output "Run cobolcheck." diff --git a/exercises/practice/isogram/test.sh b/exercises/practice/isogram/test.sh index ed4a27a1..7b4a9da0 100755 --- a/exercises/practice/isogram/test.sh +++ b/exercises/practice/isogram/test.sh @@ -1,13 +1,9 @@ #!/usr/bin/env bash SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )/ SLUG=${1:-$(basename "${SCRIPT_DIR}")} -COBOLCHECK=./bin/cobolcheck +COBOLCHECK="${HOME}/cobolcheck/cobolcheck" -WHICH_COBOLCHECK=$(which cobolcheck) -if [[ $? -eq 0 ]] ; then - echo "Found cobolcheck, using $COBOLCHECK" - COBOLCHECK=$WHICH_COBOLCHECK -elif [ ! -f $SCRIPT_DIR/bin/cobolcheck ]; then +if [ ! -f "${COBOLCHECK}" ]; then echo "Cobolcheck not found, try to fetch it." cd $SCRIPT_DIR/bin/ bash fetch-cobolcheck diff --git a/exercises/practice/knapsack/bin/fetch-cobolcheck b/exercises/practice/knapsack/bin/fetch-cobolcheck index 0b668734..b3d4adb1 100755 --- a/exercises/practice/knapsack/bin/fetch-cobolcheck +++ b/exercises/practice/knapsack/bin/fetch-cobolcheck @@ -45,19 +45,13 @@ 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_dir="${HOME}/cobolcheck" + mkdir -p "${output_dir}" output_path="${output_dir}/cobolcheck${ext}" download_url="$(get_download_url)" curl "${curlopts[@]}" --output "${output_path}" "${download_url}" chmod +x "${output_path}" + echo "Cobolcheck has been downloaded to ${output_path}" } main diff --git a/exercises/practice/knapsack/bin/fetch-cobolcheck.ps1 b/exercises/practice/knapsack/bin/fetch-cobolcheck.ps1 index a57f708d..9228452c 100644 --- a/exercises/practice/knapsack/bin/fetch-cobolcheck.ps1 +++ b/exercises/practice/knapsack/bin/fetch-cobolcheck.ps1 @@ -23,5 +23,5 @@ Function Get-DownloadUrl { } $downloadUrl = Get-DownloadUrl -$outputFile = Join-Path -Path $PSScriptRoot -ChildPath "cobolcheck.exe" +$outputFile = Join-Path -Path "${HOME}" "cobolcheck" "cobolcheck.exe" Invoke-WebRequest -Uri $downloadUrl -OutFile $outputFile @requestOpts diff --git a/exercises/practice/knapsack/test.ps1 b/exercises/practice/knapsack/test.ps1 index b54fdc61..7a2bb33b 100644 --- a/exercises/practice/knapsack/test.ps1 +++ b/exercises/practice/knapsack/test.ps1 @@ -1,13 +1,11 @@ $slug=Split-Path $PSScriptRoot -Leaf -$cobolcheck = "$PSScriptRoot\bin\cobolcheck.exe" -$cobolcheckCmd = Get-Command "cobolcheck.exe" -ErrorAction SilentlyContinue +$cobolcheck = Join-Path -Path "${HOME}" "cobolcheck" "cobolcheck.exe" -if ($cobolcheckCmd) { - $cobolcheck = $cobolcheckCmd.Path - Write-Output "Found cobolcheck, using $cobolcheck" -} elseif (![System.IO.File]::Exists("$cobolcheck")){ +if (![System.IO.File]::Exists("$cobolcheck")){ + $fetchCobolcheckPath = Join-Path -Path "${PSScriptRoot}" "bin" "fetch-cobolcheck.ps1" + echo $fetchCobolcheckPath Write-Output "Cobolcheck not found. Trying to fetch it." - & "$PSScriptRoot\bin\fetch-cobolcheck.ps1" + & "${fetchCobolcheckPath}" } Write-Output "Run cobolcheck." diff --git a/exercises/practice/knapsack/test.sh b/exercises/practice/knapsack/test.sh index ed4a27a1..7b4a9da0 100755 --- a/exercises/practice/knapsack/test.sh +++ b/exercises/practice/knapsack/test.sh @@ -1,13 +1,9 @@ #!/usr/bin/env bash SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )/ SLUG=${1:-$(basename "${SCRIPT_DIR}")} -COBOLCHECK=./bin/cobolcheck +COBOLCHECK="${HOME}/cobolcheck/cobolcheck" -WHICH_COBOLCHECK=$(which cobolcheck) -if [[ $? -eq 0 ]] ; then - echo "Found cobolcheck, using $COBOLCHECK" - COBOLCHECK=$WHICH_COBOLCHECK -elif [ ! -f $SCRIPT_DIR/bin/cobolcheck ]; then +if [ ! -f "${COBOLCHECK}" ]; then echo "Cobolcheck not found, try to fetch it." cd $SCRIPT_DIR/bin/ bash fetch-cobolcheck diff --git a/exercises/practice/leap/bin/fetch-cobolcheck b/exercises/practice/leap/bin/fetch-cobolcheck index 0b668734..b3d4adb1 100755 --- a/exercises/practice/leap/bin/fetch-cobolcheck +++ b/exercises/practice/leap/bin/fetch-cobolcheck @@ -45,19 +45,13 @@ 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_dir="${HOME}/cobolcheck" + mkdir -p "${output_dir}" output_path="${output_dir}/cobolcheck${ext}" download_url="$(get_download_url)" curl "${curlopts[@]}" --output "${output_path}" "${download_url}" chmod +x "${output_path}" + echo "Cobolcheck has been downloaded to ${output_path}" } main diff --git a/exercises/practice/leap/bin/fetch-cobolcheck.ps1 b/exercises/practice/leap/bin/fetch-cobolcheck.ps1 index a57f708d..9228452c 100644 --- a/exercises/practice/leap/bin/fetch-cobolcheck.ps1 +++ b/exercises/practice/leap/bin/fetch-cobolcheck.ps1 @@ -23,5 +23,5 @@ Function Get-DownloadUrl { } $downloadUrl = Get-DownloadUrl -$outputFile = Join-Path -Path $PSScriptRoot -ChildPath "cobolcheck.exe" +$outputFile = Join-Path -Path "${HOME}" "cobolcheck" "cobolcheck.exe" Invoke-WebRequest -Uri $downloadUrl -OutFile $outputFile @requestOpts diff --git a/exercises/practice/leap/test.ps1 b/exercises/practice/leap/test.ps1 index b54fdc61..7a2bb33b 100644 --- a/exercises/practice/leap/test.ps1 +++ b/exercises/practice/leap/test.ps1 @@ -1,13 +1,11 @@ $slug=Split-Path $PSScriptRoot -Leaf -$cobolcheck = "$PSScriptRoot\bin\cobolcheck.exe" -$cobolcheckCmd = Get-Command "cobolcheck.exe" -ErrorAction SilentlyContinue +$cobolcheck = Join-Path -Path "${HOME}" "cobolcheck" "cobolcheck.exe" -if ($cobolcheckCmd) { - $cobolcheck = $cobolcheckCmd.Path - Write-Output "Found cobolcheck, using $cobolcheck" -} elseif (![System.IO.File]::Exists("$cobolcheck")){ +if (![System.IO.File]::Exists("$cobolcheck")){ + $fetchCobolcheckPath = Join-Path -Path "${PSScriptRoot}" "bin" "fetch-cobolcheck.ps1" + echo $fetchCobolcheckPath Write-Output "Cobolcheck not found. Trying to fetch it." - & "$PSScriptRoot\bin\fetch-cobolcheck.ps1" + & "${fetchCobolcheckPath}" } Write-Output "Run cobolcheck." diff --git a/exercises/practice/leap/test.sh b/exercises/practice/leap/test.sh index 081f6fbc..7b4a9da0 100755 --- a/exercises/practice/leap/test.sh +++ b/exercises/practice/leap/test.sh @@ -1,13 +1,9 @@ #!/usr/bin/env bash SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )/ SLUG=${1:-$(basename "${SCRIPT_DIR}")} -COBOLCHECK=./bin/cobolcheck +COBOLCHECK="${HOME}/cobolcheck/cobolcheck" -WHICH_COBOLCHECK=$(which cobolcheck) -if [[ $? -eq 0 ]] ; then - echo "Found cobolcheck, using $COBOLCHECK" - COBOLCHECK=$WHICH_COBOLCHECK -elif [ ! -f $SCRIPT_DIR/bin/cobolcheck ]; then +if [ ! -f "${COBOLCHECK}" ]; then echo "Cobolcheck not found, try to fetch it." cd $SCRIPT_DIR/bin/ bash fetch-cobolcheck @@ -15,6 +11,6 @@ fi cd $SCRIPT_DIR $COBOLCHECK -p $SLUG -# compile and run +# compile and run echo "COMPILE AND RUN TEST" cobc -xj test.cob diff --git a/exercises/practice/luhn/bin/fetch-cobolcheck b/exercises/practice/luhn/bin/fetch-cobolcheck index 0b668734..b3d4adb1 100755 --- a/exercises/practice/luhn/bin/fetch-cobolcheck +++ b/exercises/practice/luhn/bin/fetch-cobolcheck @@ -45,19 +45,13 @@ 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_dir="${HOME}/cobolcheck" + mkdir -p "${output_dir}" output_path="${output_dir}/cobolcheck${ext}" download_url="$(get_download_url)" curl "${curlopts[@]}" --output "${output_path}" "${download_url}" chmod +x "${output_path}" + echo "Cobolcheck has been downloaded to ${output_path}" } main diff --git a/exercises/practice/luhn/bin/fetch-cobolcheck.ps1 b/exercises/practice/luhn/bin/fetch-cobolcheck.ps1 index a57f708d..9228452c 100644 --- a/exercises/practice/luhn/bin/fetch-cobolcheck.ps1 +++ b/exercises/practice/luhn/bin/fetch-cobolcheck.ps1 @@ -23,5 +23,5 @@ Function Get-DownloadUrl { } $downloadUrl = Get-DownloadUrl -$outputFile = Join-Path -Path $PSScriptRoot -ChildPath "cobolcheck.exe" +$outputFile = Join-Path -Path "${HOME}" "cobolcheck" "cobolcheck.exe" Invoke-WebRequest -Uri $downloadUrl -OutFile $outputFile @requestOpts diff --git a/exercises/practice/luhn/test.ps1 b/exercises/practice/luhn/test.ps1 index b54fdc61..7a2bb33b 100644 --- a/exercises/practice/luhn/test.ps1 +++ b/exercises/practice/luhn/test.ps1 @@ -1,13 +1,11 @@ $slug=Split-Path $PSScriptRoot -Leaf -$cobolcheck = "$PSScriptRoot\bin\cobolcheck.exe" -$cobolcheckCmd = Get-Command "cobolcheck.exe" -ErrorAction SilentlyContinue +$cobolcheck = Join-Path -Path "${HOME}" "cobolcheck" "cobolcheck.exe" -if ($cobolcheckCmd) { - $cobolcheck = $cobolcheckCmd.Path - Write-Output "Found cobolcheck, using $cobolcheck" -} elseif (![System.IO.File]::Exists("$cobolcheck")){ +if (![System.IO.File]::Exists("$cobolcheck")){ + $fetchCobolcheckPath = Join-Path -Path "${PSScriptRoot}" "bin" "fetch-cobolcheck.ps1" + echo $fetchCobolcheckPath Write-Output "Cobolcheck not found. Trying to fetch it." - & "$PSScriptRoot\bin\fetch-cobolcheck.ps1" + & "${fetchCobolcheckPath}" } Write-Output "Run cobolcheck." diff --git a/exercises/practice/luhn/test.sh b/exercises/practice/luhn/test.sh index ed4a27a1..7b4a9da0 100755 --- a/exercises/practice/luhn/test.sh +++ b/exercises/practice/luhn/test.sh @@ -1,13 +1,9 @@ #!/usr/bin/env bash SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )/ SLUG=${1:-$(basename "${SCRIPT_DIR}")} -COBOLCHECK=./bin/cobolcheck +COBOLCHECK="${HOME}/cobolcheck/cobolcheck" -WHICH_COBOLCHECK=$(which cobolcheck) -if [[ $? -eq 0 ]] ; then - echo "Found cobolcheck, using $COBOLCHECK" - COBOLCHECK=$WHICH_COBOLCHECK -elif [ ! -f $SCRIPT_DIR/bin/cobolcheck ]; then +if [ ! -f "${COBOLCHECK}" ]; then echo "Cobolcheck not found, try to fetch it." cd $SCRIPT_DIR/bin/ bash fetch-cobolcheck diff --git a/exercises/practice/matching-brackets/bin/fetch-cobolcheck b/exercises/practice/matching-brackets/bin/fetch-cobolcheck index 0b668734..b3d4adb1 100755 --- a/exercises/practice/matching-brackets/bin/fetch-cobolcheck +++ b/exercises/practice/matching-brackets/bin/fetch-cobolcheck @@ -45,19 +45,13 @@ 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_dir="${HOME}/cobolcheck" + mkdir -p "${output_dir}" output_path="${output_dir}/cobolcheck${ext}" download_url="$(get_download_url)" curl "${curlopts[@]}" --output "${output_path}" "${download_url}" chmod +x "${output_path}" + echo "Cobolcheck has been downloaded to ${output_path}" } main diff --git a/exercises/practice/matching-brackets/bin/fetch-cobolcheck.ps1 b/exercises/practice/matching-brackets/bin/fetch-cobolcheck.ps1 index a57f708d..9228452c 100644 --- a/exercises/practice/matching-brackets/bin/fetch-cobolcheck.ps1 +++ b/exercises/practice/matching-brackets/bin/fetch-cobolcheck.ps1 @@ -23,5 +23,5 @@ Function Get-DownloadUrl { } $downloadUrl = Get-DownloadUrl -$outputFile = Join-Path -Path $PSScriptRoot -ChildPath "cobolcheck.exe" +$outputFile = Join-Path -Path "${HOME}" "cobolcheck" "cobolcheck.exe" Invoke-WebRequest -Uri $downloadUrl -OutFile $outputFile @requestOpts diff --git a/exercises/practice/matching-brackets/test.ps1 b/exercises/practice/matching-brackets/test.ps1 index b54fdc61..7a2bb33b 100644 --- a/exercises/practice/matching-brackets/test.ps1 +++ b/exercises/practice/matching-brackets/test.ps1 @@ -1,13 +1,11 @@ $slug=Split-Path $PSScriptRoot -Leaf -$cobolcheck = "$PSScriptRoot\bin\cobolcheck.exe" -$cobolcheckCmd = Get-Command "cobolcheck.exe" -ErrorAction SilentlyContinue +$cobolcheck = Join-Path -Path "${HOME}" "cobolcheck" "cobolcheck.exe" -if ($cobolcheckCmd) { - $cobolcheck = $cobolcheckCmd.Path - Write-Output "Found cobolcheck, using $cobolcheck" -} elseif (![System.IO.File]::Exists("$cobolcheck")){ +if (![System.IO.File]::Exists("$cobolcheck")){ + $fetchCobolcheckPath = Join-Path -Path "${PSScriptRoot}" "bin" "fetch-cobolcheck.ps1" + echo $fetchCobolcheckPath Write-Output "Cobolcheck not found. Trying to fetch it." - & "$PSScriptRoot\bin\fetch-cobolcheck.ps1" + & "${fetchCobolcheckPath}" } Write-Output "Run cobolcheck." diff --git a/exercises/practice/matching-brackets/test.sh b/exercises/practice/matching-brackets/test.sh index ed4a27a1..7b4a9da0 100644 --- a/exercises/practice/matching-brackets/test.sh +++ b/exercises/practice/matching-brackets/test.sh @@ -1,13 +1,9 @@ #!/usr/bin/env bash SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )/ SLUG=${1:-$(basename "${SCRIPT_DIR}")} -COBOLCHECK=./bin/cobolcheck +COBOLCHECK="${HOME}/cobolcheck/cobolcheck" -WHICH_COBOLCHECK=$(which cobolcheck) -if [[ $? -eq 0 ]] ; then - echo "Found cobolcheck, using $COBOLCHECK" - COBOLCHECK=$WHICH_COBOLCHECK -elif [ ! -f $SCRIPT_DIR/bin/cobolcheck ]; then +if [ ! -f "${COBOLCHECK}" ]; then echo "Cobolcheck not found, try to fetch it." cd $SCRIPT_DIR/bin/ bash fetch-cobolcheck diff --git a/exercises/practice/meetup/bin/fetch-cobolcheck b/exercises/practice/meetup/bin/fetch-cobolcheck index 0b668734..b3d4adb1 100755 --- a/exercises/practice/meetup/bin/fetch-cobolcheck +++ b/exercises/practice/meetup/bin/fetch-cobolcheck @@ -45,19 +45,13 @@ 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_dir="${HOME}/cobolcheck" + mkdir -p "${output_dir}" output_path="${output_dir}/cobolcheck${ext}" download_url="$(get_download_url)" curl "${curlopts[@]}" --output "${output_path}" "${download_url}" chmod +x "${output_path}" + echo "Cobolcheck has been downloaded to ${output_path}" } main diff --git a/exercises/practice/meetup/bin/fetch-cobolcheck.ps1 b/exercises/practice/meetup/bin/fetch-cobolcheck.ps1 index a57f708d..9228452c 100644 --- a/exercises/practice/meetup/bin/fetch-cobolcheck.ps1 +++ b/exercises/practice/meetup/bin/fetch-cobolcheck.ps1 @@ -23,5 +23,5 @@ Function Get-DownloadUrl { } $downloadUrl = Get-DownloadUrl -$outputFile = Join-Path -Path $PSScriptRoot -ChildPath "cobolcheck.exe" +$outputFile = Join-Path -Path "${HOME}" "cobolcheck" "cobolcheck.exe" Invoke-WebRequest -Uri $downloadUrl -OutFile $outputFile @requestOpts diff --git a/exercises/practice/meetup/test.ps1 b/exercises/practice/meetup/test.ps1 index ccfa530a..7a2bb33b 100644 --- a/exercises/practice/meetup/test.ps1 +++ b/exercises/practice/meetup/test.ps1 @@ -1,14 +1,17 @@ $slug=Split-Path $PSScriptRoot -Leaf +$cobolcheck = Join-Path -Path "${HOME}" "cobolcheck" "cobolcheck.exe" -if (![System.IO.File]::Exists("$PSScriptRoot\bin\cobolcheck.exe")){ +if (![System.IO.File]::Exists("$cobolcheck")){ + $fetchCobolcheckPath = Join-Path -Path "${PSScriptRoot}" "bin" "fetch-cobolcheck.ps1" + echo $fetchCobolcheckPath Write-Output "Cobolcheck not found. Trying to fetch it." - & "$PSScriptRoot\bin\fetch-cobolcheck.ps1" + & "${fetchCobolcheckPath}" } Write-Output "Run cobolcheck." Set-Location $PSScriptRoot -Invoke-Expression "bin\cobolcheck.exe -p $slug" +Invoke-Expression "$cobolcheck -p $slug" Invoke-Expression "cobc -xj test.cob" if ($Lastexitcode -ne 0) { diff --git a/exercises/practice/meetup/test.sh b/exercises/practice/meetup/test.sh index ed4a27a1..7b4a9da0 100755 --- a/exercises/practice/meetup/test.sh +++ b/exercises/practice/meetup/test.sh @@ -1,13 +1,9 @@ #!/usr/bin/env bash SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )/ SLUG=${1:-$(basename "${SCRIPT_DIR}")} -COBOLCHECK=./bin/cobolcheck +COBOLCHECK="${HOME}/cobolcheck/cobolcheck" -WHICH_COBOLCHECK=$(which cobolcheck) -if [[ $? -eq 0 ]] ; then - echo "Found cobolcheck, using $COBOLCHECK" - COBOLCHECK=$WHICH_COBOLCHECK -elif [ ! -f $SCRIPT_DIR/bin/cobolcheck ]; then +if [ ! -f "${COBOLCHECK}" ]; then echo "Cobolcheck not found, try to fetch it." cd $SCRIPT_DIR/bin/ bash fetch-cobolcheck diff --git a/exercises/practice/nucleotide-count/bin/fetch-cobolcheck b/exercises/practice/nucleotide-count/bin/fetch-cobolcheck index 0b668734..b3d4adb1 100755 --- a/exercises/practice/nucleotide-count/bin/fetch-cobolcheck +++ b/exercises/practice/nucleotide-count/bin/fetch-cobolcheck @@ -45,19 +45,13 @@ 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_dir="${HOME}/cobolcheck" + mkdir -p "${output_dir}" output_path="${output_dir}/cobolcheck${ext}" download_url="$(get_download_url)" curl "${curlopts[@]}" --output "${output_path}" "${download_url}" chmod +x "${output_path}" + echo "Cobolcheck has been downloaded to ${output_path}" } main diff --git a/exercises/practice/nucleotide-count/bin/fetch-cobolcheck.ps1 b/exercises/practice/nucleotide-count/bin/fetch-cobolcheck.ps1 index a57f708d..9228452c 100644 --- a/exercises/practice/nucleotide-count/bin/fetch-cobolcheck.ps1 +++ b/exercises/practice/nucleotide-count/bin/fetch-cobolcheck.ps1 @@ -23,5 +23,5 @@ Function Get-DownloadUrl { } $downloadUrl = Get-DownloadUrl -$outputFile = Join-Path -Path $PSScriptRoot -ChildPath "cobolcheck.exe" +$outputFile = Join-Path -Path "${HOME}" "cobolcheck" "cobolcheck.exe" Invoke-WebRequest -Uri $downloadUrl -OutFile $outputFile @requestOpts diff --git a/exercises/practice/nucleotide-count/test.ps1 b/exercises/practice/nucleotide-count/test.ps1 index b54fdc61..7a2bb33b 100644 --- a/exercises/practice/nucleotide-count/test.ps1 +++ b/exercises/practice/nucleotide-count/test.ps1 @@ -1,13 +1,11 @@ $slug=Split-Path $PSScriptRoot -Leaf -$cobolcheck = "$PSScriptRoot\bin\cobolcheck.exe" -$cobolcheckCmd = Get-Command "cobolcheck.exe" -ErrorAction SilentlyContinue +$cobolcheck = Join-Path -Path "${HOME}" "cobolcheck" "cobolcheck.exe" -if ($cobolcheckCmd) { - $cobolcheck = $cobolcheckCmd.Path - Write-Output "Found cobolcheck, using $cobolcheck" -} elseif (![System.IO.File]::Exists("$cobolcheck")){ +if (![System.IO.File]::Exists("$cobolcheck")){ + $fetchCobolcheckPath = Join-Path -Path "${PSScriptRoot}" "bin" "fetch-cobolcheck.ps1" + echo $fetchCobolcheckPath Write-Output "Cobolcheck not found. Trying to fetch it." - & "$PSScriptRoot\bin\fetch-cobolcheck.ps1" + & "${fetchCobolcheckPath}" } Write-Output "Run cobolcheck." diff --git a/exercises/practice/nucleotide-count/test.sh b/exercises/practice/nucleotide-count/test.sh index 8bb4caa3..7b4a9da0 100755 --- a/exercises/practice/nucleotide-count/test.sh +++ b/exercises/practice/nucleotide-count/test.sh @@ -1,13 +1,9 @@ #!/usr/bin/env bash SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )/ SLUG=${1:-$(basename "${SCRIPT_DIR}")} -COBOLCHECK=./bin/cobolcheck +COBOLCHECK="${HOME}/cobolcheck/cobolcheck" -WHICH_COBOLCHECK=$(which cobolcheck) -if [[ $? -eq 0 ]] ; then - echo "Found cobolcheck, using $COBOLCHECK" - COBOLCHECK=$WHICH_COBOLCHECK -elif [ ! -f $SCRIPT_DIR/bin/cobolcheck ]; then +if [ ! -f "${COBOLCHECK}" ]; then echo "Cobolcheck not found, try to fetch it." cd $SCRIPT_DIR/bin/ bash fetch-cobolcheck @@ -18,4 +14,3 @@ $COBOLCHECK -p $SLUG # compile and run echo "COMPILE AND RUN TEST" cobc -xj test.cob - diff --git a/exercises/practice/pangram/bin/fetch-cobolcheck b/exercises/practice/pangram/bin/fetch-cobolcheck index 0b668734..b3d4adb1 100755 --- a/exercises/practice/pangram/bin/fetch-cobolcheck +++ b/exercises/practice/pangram/bin/fetch-cobolcheck @@ -45,19 +45,13 @@ 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_dir="${HOME}/cobolcheck" + mkdir -p "${output_dir}" output_path="${output_dir}/cobolcheck${ext}" download_url="$(get_download_url)" curl "${curlopts[@]}" --output "${output_path}" "${download_url}" chmod +x "${output_path}" + echo "Cobolcheck has been downloaded to ${output_path}" } main diff --git a/exercises/practice/pangram/bin/fetch-cobolcheck.ps1 b/exercises/practice/pangram/bin/fetch-cobolcheck.ps1 index a57f708d..9228452c 100644 --- a/exercises/practice/pangram/bin/fetch-cobolcheck.ps1 +++ b/exercises/practice/pangram/bin/fetch-cobolcheck.ps1 @@ -23,5 +23,5 @@ Function Get-DownloadUrl { } $downloadUrl = Get-DownloadUrl -$outputFile = Join-Path -Path $PSScriptRoot -ChildPath "cobolcheck.exe" +$outputFile = Join-Path -Path "${HOME}" "cobolcheck" "cobolcheck.exe" Invoke-WebRequest -Uri $downloadUrl -OutFile $outputFile @requestOpts diff --git a/exercises/practice/pangram/test.ps1 b/exercises/practice/pangram/test.ps1 index b54fdc61..7a2bb33b 100644 --- a/exercises/practice/pangram/test.ps1 +++ b/exercises/practice/pangram/test.ps1 @@ -1,13 +1,11 @@ $slug=Split-Path $PSScriptRoot -Leaf -$cobolcheck = "$PSScriptRoot\bin\cobolcheck.exe" -$cobolcheckCmd = Get-Command "cobolcheck.exe" -ErrorAction SilentlyContinue +$cobolcheck = Join-Path -Path "${HOME}" "cobolcheck" "cobolcheck.exe" -if ($cobolcheckCmd) { - $cobolcheck = $cobolcheckCmd.Path - Write-Output "Found cobolcheck, using $cobolcheck" -} elseif (![System.IO.File]::Exists("$cobolcheck")){ +if (![System.IO.File]::Exists("$cobolcheck")){ + $fetchCobolcheckPath = Join-Path -Path "${PSScriptRoot}" "bin" "fetch-cobolcheck.ps1" + echo $fetchCobolcheckPath Write-Output "Cobolcheck not found. Trying to fetch it." - & "$PSScriptRoot\bin\fetch-cobolcheck.ps1" + & "${fetchCobolcheckPath}" } Write-Output "Run cobolcheck." diff --git a/exercises/practice/pangram/test.sh b/exercises/practice/pangram/test.sh index ed4a27a1..7b4a9da0 100755 --- a/exercises/practice/pangram/test.sh +++ b/exercises/practice/pangram/test.sh @@ -1,13 +1,9 @@ #!/usr/bin/env bash SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )/ SLUG=${1:-$(basename "${SCRIPT_DIR}")} -COBOLCHECK=./bin/cobolcheck +COBOLCHECK="${HOME}/cobolcheck/cobolcheck" -WHICH_COBOLCHECK=$(which cobolcheck) -if [[ $? -eq 0 ]] ; then - echo "Found cobolcheck, using $COBOLCHECK" - COBOLCHECK=$WHICH_COBOLCHECK -elif [ ! -f $SCRIPT_DIR/bin/cobolcheck ]; then +if [ ! -f "${COBOLCHECK}" ]; then echo "Cobolcheck not found, try to fetch it." cd $SCRIPT_DIR/bin/ bash fetch-cobolcheck diff --git a/exercises/practice/pascals-triangle/bin/fetch-cobolcheck b/exercises/practice/pascals-triangle/bin/fetch-cobolcheck index 0b668734..b3d4adb1 100755 --- a/exercises/practice/pascals-triangle/bin/fetch-cobolcheck +++ b/exercises/practice/pascals-triangle/bin/fetch-cobolcheck @@ -45,19 +45,13 @@ 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_dir="${HOME}/cobolcheck" + mkdir -p "${output_dir}" output_path="${output_dir}/cobolcheck${ext}" download_url="$(get_download_url)" curl "${curlopts[@]}" --output "${output_path}" "${download_url}" chmod +x "${output_path}" + echo "Cobolcheck has been downloaded to ${output_path}" } main diff --git a/exercises/practice/pascals-triangle/bin/fetch-cobolcheck.ps1 b/exercises/practice/pascals-triangle/bin/fetch-cobolcheck.ps1 index a57f708d..9228452c 100644 --- a/exercises/practice/pascals-triangle/bin/fetch-cobolcheck.ps1 +++ b/exercises/practice/pascals-triangle/bin/fetch-cobolcheck.ps1 @@ -23,5 +23,5 @@ Function Get-DownloadUrl { } $downloadUrl = Get-DownloadUrl -$outputFile = Join-Path -Path $PSScriptRoot -ChildPath "cobolcheck.exe" +$outputFile = Join-Path -Path "${HOME}" "cobolcheck" "cobolcheck.exe" Invoke-WebRequest -Uri $downloadUrl -OutFile $outputFile @requestOpts diff --git a/exercises/practice/pascals-triangle/test.ps1 b/exercises/practice/pascals-triangle/test.ps1 index b54fdc61..7a2bb33b 100644 --- a/exercises/practice/pascals-triangle/test.ps1 +++ b/exercises/practice/pascals-triangle/test.ps1 @@ -1,13 +1,11 @@ $slug=Split-Path $PSScriptRoot -Leaf -$cobolcheck = "$PSScriptRoot\bin\cobolcheck.exe" -$cobolcheckCmd = Get-Command "cobolcheck.exe" -ErrorAction SilentlyContinue +$cobolcheck = Join-Path -Path "${HOME}" "cobolcheck" "cobolcheck.exe" -if ($cobolcheckCmd) { - $cobolcheck = $cobolcheckCmd.Path - Write-Output "Found cobolcheck, using $cobolcheck" -} elseif (![System.IO.File]::Exists("$cobolcheck")){ +if (![System.IO.File]::Exists("$cobolcheck")){ + $fetchCobolcheckPath = Join-Path -Path "${PSScriptRoot}" "bin" "fetch-cobolcheck.ps1" + echo $fetchCobolcheckPath Write-Output "Cobolcheck not found. Trying to fetch it." - & "$PSScriptRoot\bin\fetch-cobolcheck.ps1" + & "${fetchCobolcheckPath}" } Write-Output "Run cobolcheck." diff --git a/exercises/practice/pascals-triangle/test.sh b/exercises/practice/pascals-triangle/test.sh index ed4a27a1..7b4a9da0 100644 --- a/exercises/practice/pascals-triangle/test.sh +++ b/exercises/practice/pascals-triangle/test.sh @@ -1,13 +1,9 @@ #!/usr/bin/env bash SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )/ SLUG=${1:-$(basename "${SCRIPT_DIR}")} -COBOLCHECK=./bin/cobolcheck +COBOLCHECK="${HOME}/cobolcheck/cobolcheck" -WHICH_COBOLCHECK=$(which cobolcheck) -if [[ $? -eq 0 ]] ; then - echo "Found cobolcheck, using $COBOLCHECK" - COBOLCHECK=$WHICH_COBOLCHECK -elif [ ! -f $SCRIPT_DIR/bin/cobolcheck ]; then +if [ ! -f "${COBOLCHECK}" ]; then echo "Cobolcheck not found, try to fetch it." cd $SCRIPT_DIR/bin/ bash fetch-cobolcheck diff --git a/exercises/practice/pig-latin/bin/fetch-cobolcheck b/exercises/practice/pig-latin/bin/fetch-cobolcheck index 0b668734..b3d4adb1 100755 --- a/exercises/practice/pig-latin/bin/fetch-cobolcheck +++ b/exercises/practice/pig-latin/bin/fetch-cobolcheck @@ -45,19 +45,13 @@ 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_dir="${HOME}/cobolcheck" + mkdir -p "${output_dir}" output_path="${output_dir}/cobolcheck${ext}" download_url="$(get_download_url)" curl "${curlopts[@]}" --output "${output_path}" "${download_url}" chmod +x "${output_path}" + echo "Cobolcheck has been downloaded to ${output_path}" } main diff --git a/exercises/practice/pig-latin/bin/fetch-cobolcheck.ps1 b/exercises/practice/pig-latin/bin/fetch-cobolcheck.ps1 index a57f708d..9228452c 100644 --- a/exercises/practice/pig-latin/bin/fetch-cobolcheck.ps1 +++ b/exercises/practice/pig-latin/bin/fetch-cobolcheck.ps1 @@ -23,5 +23,5 @@ Function Get-DownloadUrl { } $downloadUrl = Get-DownloadUrl -$outputFile = Join-Path -Path $PSScriptRoot -ChildPath "cobolcheck.exe" +$outputFile = Join-Path -Path "${HOME}" "cobolcheck" "cobolcheck.exe" Invoke-WebRequest -Uri $downloadUrl -OutFile $outputFile @requestOpts diff --git a/exercises/practice/pig-latin/test.ps1 b/exercises/practice/pig-latin/test.ps1 index ccfa530a..7a2bb33b 100644 --- a/exercises/practice/pig-latin/test.ps1 +++ b/exercises/practice/pig-latin/test.ps1 @@ -1,14 +1,17 @@ $slug=Split-Path $PSScriptRoot -Leaf +$cobolcheck = Join-Path -Path "${HOME}" "cobolcheck" "cobolcheck.exe" -if (![System.IO.File]::Exists("$PSScriptRoot\bin\cobolcheck.exe")){ +if (![System.IO.File]::Exists("$cobolcheck")){ + $fetchCobolcheckPath = Join-Path -Path "${PSScriptRoot}" "bin" "fetch-cobolcheck.ps1" + echo $fetchCobolcheckPath Write-Output "Cobolcheck not found. Trying to fetch it." - & "$PSScriptRoot\bin\fetch-cobolcheck.ps1" + & "${fetchCobolcheckPath}" } Write-Output "Run cobolcheck." Set-Location $PSScriptRoot -Invoke-Expression "bin\cobolcheck.exe -p $slug" +Invoke-Expression "$cobolcheck -p $slug" Invoke-Expression "cobc -xj test.cob" if ($Lastexitcode -ne 0) { diff --git a/exercises/practice/pig-latin/test.sh b/exercises/practice/pig-latin/test.sh index ed4a27a1..7b4a9da0 100755 --- a/exercises/practice/pig-latin/test.sh +++ b/exercises/practice/pig-latin/test.sh @@ -1,13 +1,9 @@ #!/usr/bin/env bash SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )/ SLUG=${1:-$(basename "${SCRIPT_DIR}")} -COBOLCHECK=./bin/cobolcheck +COBOLCHECK="${HOME}/cobolcheck/cobolcheck" -WHICH_COBOLCHECK=$(which cobolcheck) -if [[ $? -eq 0 ]] ; then - echo "Found cobolcheck, using $COBOLCHECK" - COBOLCHECK=$WHICH_COBOLCHECK -elif [ ! -f $SCRIPT_DIR/bin/cobolcheck ]; then +if [ ! -f "${COBOLCHECK}" ]; then echo "Cobolcheck not found, try to fetch it." cd $SCRIPT_DIR/bin/ bash fetch-cobolcheck diff --git a/exercises/practice/protein-translation/bin/fetch-cobolcheck b/exercises/practice/protein-translation/bin/fetch-cobolcheck index 0b668734..b3d4adb1 100755 --- a/exercises/practice/protein-translation/bin/fetch-cobolcheck +++ b/exercises/practice/protein-translation/bin/fetch-cobolcheck @@ -45,19 +45,13 @@ 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_dir="${HOME}/cobolcheck" + mkdir -p "${output_dir}" output_path="${output_dir}/cobolcheck${ext}" download_url="$(get_download_url)" curl "${curlopts[@]}" --output "${output_path}" "${download_url}" chmod +x "${output_path}" + echo "Cobolcheck has been downloaded to ${output_path}" } main diff --git a/exercises/practice/protein-translation/bin/fetch-cobolcheck.ps1 b/exercises/practice/protein-translation/bin/fetch-cobolcheck.ps1 index a57f708d..9228452c 100644 --- a/exercises/practice/protein-translation/bin/fetch-cobolcheck.ps1 +++ b/exercises/practice/protein-translation/bin/fetch-cobolcheck.ps1 @@ -23,5 +23,5 @@ Function Get-DownloadUrl { } $downloadUrl = Get-DownloadUrl -$outputFile = Join-Path -Path $PSScriptRoot -ChildPath "cobolcheck.exe" +$outputFile = Join-Path -Path "${HOME}" "cobolcheck" "cobolcheck.exe" Invoke-WebRequest -Uri $downloadUrl -OutFile $outputFile @requestOpts diff --git a/exercises/practice/protein-translation/test.ps1 b/exercises/practice/protein-translation/test.ps1 index ccfa530a..7a2bb33b 100644 --- a/exercises/practice/protein-translation/test.ps1 +++ b/exercises/practice/protein-translation/test.ps1 @@ -1,14 +1,17 @@ $slug=Split-Path $PSScriptRoot -Leaf +$cobolcheck = Join-Path -Path "${HOME}" "cobolcheck" "cobolcheck.exe" -if (![System.IO.File]::Exists("$PSScriptRoot\bin\cobolcheck.exe")){ +if (![System.IO.File]::Exists("$cobolcheck")){ + $fetchCobolcheckPath = Join-Path -Path "${PSScriptRoot}" "bin" "fetch-cobolcheck.ps1" + echo $fetchCobolcheckPath Write-Output "Cobolcheck not found. Trying to fetch it." - & "$PSScriptRoot\bin\fetch-cobolcheck.ps1" + & "${fetchCobolcheckPath}" } Write-Output "Run cobolcheck." Set-Location $PSScriptRoot -Invoke-Expression "bin\cobolcheck.exe -p $slug" +Invoke-Expression "$cobolcheck -p $slug" Invoke-Expression "cobc -xj test.cob" if ($Lastexitcode -ne 0) { diff --git a/exercises/practice/protein-translation/test.sh b/exercises/practice/protein-translation/test.sh index ed4a27a1..7b4a9da0 100755 --- a/exercises/practice/protein-translation/test.sh +++ b/exercises/practice/protein-translation/test.sh @@ -1,13 +1,9 @@ #!/usr/bin/env bash SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )/ SLUG=${1:-$(basename "${SCRIPT_DIR}")} -COBOLCHECK=./bin/cobolcheck +COBOLCHECK="${HOME}/cobolcheck/cobolcheck" -WHICH_COBOLCHECK=$(which cobolcheck) -if [[ $? -eq 0 ]] ; then - echo "Found cobolcheck, using $COBOLCHECK" - COBOLCHECK=$WHICH_COBOLCHECK -elif [ ! -f $SCRIPT_DIR/bin/cobolcheck ]; then +if [ ! -f "${COBOLCHECK}" ]; then echo "Cobolcheck not found, try to fetch it." cd $SCRIPT_DIR/bin/ bash fetch-cobolcheck diff --git a/exercises/practice/queen-attack/bin/fetch-cobolcheck b/exercises/practice/queen-attack/bin/fetch-cobolcheck index 0b668734..b3d4adb1 100644 --- a/exercises/practice/queen-attack/bin/fetch-cobolcheck +++ b/exercises/practice/queen-attack/bin/fetch-cobolcheck @@ -45,19 +45,13 @@ 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_dir="${HOME}/cobolcheck" + mkdir -p "${output_dir}" output_path="${output_dir}/cobolcheck${ext}" download_url="$(get_download_url)" curl "${curlopts[@]}" --output "${output_path}" "${download_url}" chmod +x "${output_path}" + echo "Cobolcheck has been downloaded to ${output_path}" } main diff --git a/exercises/practice/queen-attack/bin/fetch-cobolcheck.ps1 b/exercises/practice/queen-attack/bin/fetch-cobolcheck.ps1 index a57f708d..9228452c 100644 --- a/exercises/practice/queen-attack/bin/fetch-cobolcheck.ps1 +++ b/exercises/practice/queen-attack/bin/fetch-cobolcheck.ps1 @@ -23,5 +23,5 @@ Function Get-DownloadUrl { } $downloadUrl = Get-DownloadUrl -$outputFile = Join-Path -Path $PSScriptRoot -ChildPath "cobolcheck.exe" +$outputFile = Join-Path -Path "${HOME}" "cobolcheck" "cobolcheck.exe" Invoke-WebRequest -Uri $downloadUrl -OutFile $outputFile @requestOpts diff --git a/exercises/practice/queen-attack/test.ps1 b/exercises/practice/queen-attack/test.ps1 index b54fdc61..7a2bb33b 100644 --- a/exercises/practice/queen-attack/test.ps1 +++ b/exercises/practice/queen-attack/test.ps1 @@ -1,13 +1,11 @@ $slug=Split-Path $PSScriptRoot -Leaf -$cobolcheck = "$PSScriptRoot\bin\cobolcheck.exe" -$cobolcheckCmd = Get-Command "cobolcheck.exe" -ErrorAction SilentlyContinue +$cobolcheck = Join-Path -Path "${HOME}" "cobolcheck" "cobolcheck.exe" -if ($cobolcheckCmd) { - $cobolcheck = $cobolcheckCmd.Path - Write-Output "Found cobolcheck, using $cobolcheck" -} elseif (![System.IO.File]::Exists("$cobolcheck")){ +if (![System.IO.File]::Exists("$cobolcheck")){ + $fetchCobolcheckPath = Join-Path -Path "${PSScriptRoot}" "bin" "fetch-cobolcheck.ps1" + echo $fetchCobolcheckPath Write-Output "Cobolcheck not found. Trying to fetch it." - & "$PSScriptRoot\bin\fetch-cobolcheck.ps1" + & "${fetchCobolcheckPath}" } Write-Output "Run cobolcheck." diff --git a/exercises/practice/queen-attack/test.sh b/exercises/practice/queen-attack/test.sh index ed4a27a1..7b4a9da0 100755 --- a/exercises/practice/queen-attack/test.sh +++ b/exercises/practice/queen-attack/test.sh @@ -1,13 +1,9 @@ #!/usr/bin/env bash SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )/ SLUG=${1:-$(basename "${SCRIPT_DIR}")} -COBOLCHECK=./bin/cobolcheck +COBOLCHECK="${HOME}/cobolcheck/cobolcheck" -WHICH_COBOLCHECK=$(which cobolcheck) -if [[ $? -eq 0 ]] ; then - echo "Found cobolcheck, using $COBOLCHECK" - COBOLCHECK=$WHICH_COBOLCHECK -elif [ ! -f $SCRIPT_DIR/bin/cobolcheck ]; then +if [ ! -f "${COBOLCHECK}" ]; then echo "Cobolcheck not found, try to fetch it." cd $SCRIPT_DIR/bin/ bash fetch-cobolcheck diff --git a/exercises/practice/raindrops/bin/fetch-cobolcheck b/exercises/practice/raindrops/bin/fetch-cobolcheck index 0b668734..b3d4adb1 100755 --- a/exercises/practice/raindrops/bin/fetch-cobolcheck +++ b/exercises/practice/raindrops/bin/fetch-cobolcheck @@ -45,19 +45,13 @@ 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_dir="${HOME}/cobolcheck" + mkdir -p "${output_dir}" output_path="${output_dir}/cobolcheck${ext}" download_url="$(get_download_url)" curl "${curlopts[@]}" --output "${output_path}" "${download_url}" chmod +x "${output_path}" + echo "Cobolcheck has been downloaded to ${output_path}" } main diff --git a/exercises/practice/raindrops/bin/fetch-cobolcheck.ps1 b/exercises/practice/raindrops/bin/fetch-cobolcheck.ps1 index a57f708d..9228452c 100644 --- a/exercises/practice/raindrops/bin/fetch-cobolcheck.ps1 +++ b/exercises/practice/raindrops/bin/fetch-cobolcheck.ps1 @@ -23,5 +23,5 @@ Function Get-DownloadUrl { } $downloadUrl = Get-DownloadUrl -$outputFile = Join-Path -Path $PSScriptRoot -ChildPath "cobolcheck.exe" +$outputFile = Join-Path -Path "${HOME}" "cobolcheck" "cobolcheck.exe" Invoke-WebRequest -Uri $downloadUrl -OutFile $outputFile @requestOpts diff --git a/exercises/practice/raindrops/test.ps1 b/exercises/practice/raindrops/test.ps1 index b54fdc61..7a2bb33b 100644 --- a/exercises/practice/raindrops/test.ps1 +++ b/exercises/practice/raindrops/test.ps1 @@ -1,13 +1,11 @@ $slug=Split-Path $PSScriptRoot -Leaf -$cobolcheck = "$PSScriptRoot\bin\cobolcheck.exe" -$cobolcheckCmd = Get-Command "cobolcheck.exe" -ErrorAction SilentlyContinue +$cobolcheck = Join-Path -Path "${HOME}" "cobolcheck" "cobolcheck.exe" -if ($cobolcheckCmd) { - $cobolcheck = $cobolcheckCmd.Path - Write-Output "Found cobolcheck, using $cobolcheck" -} elseif (![System.IO.File]::Exists("$cobolcheck")){ +if (![System.IO.File]::Exists("$cobolcheck")){ + $fetchCobolcheckPath = Join-Path -Path "${PSScriptRoot}" "bin" "fetch-cobolcheck.ps1" + echo $fetchCobolcheckPath Write-Output "Cobolcheck not found. Trying to fetch it." - & "$PSScriptRoot\bin\fetch-cobolcheck.ps1" + & "${fetchCobolcheckPath}" } Write-Output "Run cobolcheck." diff --git a/exercises/practice/raindrops/test.sh b/exercises/practice/raindrops/test.sh index ed4a27a1..7b4a9da0 100755 --- a/exercises/practice/raindrops/test.sh +++ b/exercises/practice/raindrops/test.sh @@ -1,13 +1,9 @@ #!/usr/bin/env bash SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )/ SLUG=${1:-$(basename "${SCRIPT_DIR}")} -COBOLCHECK=./bin/cobolcheck +COBOLCHECK="${HOME}/cobolcheck/cobolcheck" -WHICH_COBOLCHECK=$(which cobolcheck) -if [[ $? -eq 0 ]] ; then - echo "Found cobolcheck, using $COBOLCHECK" - COBOLCHECK=$WHICH_COBOLCHECK -elif [ ! -f $SCRIPT_DIR/bin/cobolcheck ]; then +if [ ! -f "${COBOLCHECK}" ]; then echo "Cobolcheck not found, try to fetch it." cd $SCRIPT_DIR/bin/ bash fetch-cobolcheck diff --git a/exercises/practice/reverse-string/bin/fetch-cobolcheck b/exercises/practice/reverse-string/bin/fetch-cobolcheck index 0b668734..b3d4adb1 100755 --- a/exercises/practice/reverse-string/bin/fetch-cobolcheck +++ b/exercises/practice/reverse-string/bin/fetch-cobolcheck @@ -45,19 +45,13 @@ 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_dir="${HOME}/cobolcheck" + mkdir -p "${output_dir}" output_path="${output_dir}/cobolcheck${ext}" download_url="$(get_download_url)" curl "${curlopts[@]}" --output "${output_path}" "${download_url}" chmod +x "${output_path}" + echo "Cobolcheck has been downloaded to ${output_path}" } main diff --git a/exercises/practice/reverse-string/bin/fetch-cobolcheck.ps1 b/exercises/practice/reverse-string/bin/fetch-cobolcheck.ps1 index a57f708d..9228452c 100644 --- a/exercises/practice/reverse-string/bin/fetch-cobolcheck.ps1 +++ b/exercises/practice/reverse-string/bin/fetch-cobolcheck.ps1 @@ -23,5 +23,5 @@ Function Get-DownloadUrl { } $downloadUrl = Get-DownloadUrl -$outputFile = Join-Path -Path $PSScriptRoot -ChildPath "cobolcheck.exe" +$outputFile = Join-Path -Path "${HOME}" "cobolcheck" "cobolcheck.exe" Invoke-WebRequest -Uri $downloadUrl -OutFile $outputFile @requestOpts diff --git a/exercises/practice/reverse-string/test.ps1 b/exercises/practice/reverse-string/test.ps1 index b54fdc61..7a2bb33b 100644 --- a/exercises/practice/reverse-string/test.ps1 +++ b/exercises/practice/reverse-string/test.ps1 @@ -1,13 +1,11 @@ $slug=Split-Path $PSScriptRoot -Leaf -$cobolcheck = "$PSScriptRoot\bin\cobolcheck.exe" -$cobolcheckCmd = Get-Command "cobolcheck.exe" -ErrorAction SilentlyContinue +$cobolcheck = Join-Path -Path "${HOME}" "cobolcheck" "cobolcheck.exe" -if ($cobolcheckCmd) { - $cobolcheck = $cobolcheckCmd.Path - Write-Output "Found cobolcheck, using $cobolcheck" -} elseif (![System.IO.File]::Exists("$cobolcheck")){ +if (![System.IO.File]::Exists("$cobolcheck")){ + $fetchCobolcheckPath = Join-Path -Path "${PSScriptRoot}" "bin" "fetch-cobolcheck.ps1" + echo $fetchCobolcheckPath Write-Output "Cobolcheck not found. Trying to fetch it." - & "$PSScriptRoot\bin\fetch-cobolcheck.ps1" + & "${fetchCobolcheckPath}" } Write-Output "Run cobolcheck." diff --git a/exercises/practice/reverse-string/test.sh b/exercises/practice/reverse-string/test.sh index ed4a27a1..7b4a9da0 100755 --- a/exercises/practice/reverse-string/test.sh +++ b/exercises/practice/reverse-string/test.sh @@ -1,13 +1,9 @@ #!/usr/bin/env bash SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )/ SLUG=${1:-$(basename "${SCRIPT_DIR}")} -COBOLCHECK=./bin/cobolcheck +COBOLCHECK="${HOME}/cobolcheck/cobolcheck" -WHICH_COBOLCHECK=$(which cobolcheck) -if [[ $? -eq 0 ]] ; then - echo "Found cobolcheck, using $COBOLCHECK" - COBOLCHECK=$WHICH_COBOLCHECK -elif [ ! -f $SCRIPT_DIR/bin/cobolcheck ]; then +if [ ! -f "${COBOLCHECK}" ]; then echo "Cobolcheck not found, try to fetch it." cd $SCRIPT_DIR/bin/ bash fetch-cobolcheck diff --git a/exercises/practice/rna-transcription/bin/fetch-cobolcheck b/exercises/practice/rna-transcription/bin/fetch-cobolcheck index 0b668734..b3d4adb1 100755 --- a/exercises/practice/rna-transcription/bin/fetch-cobolcheck +++ b/exercises/practice/rna-transcription/bin/fetch-cobolcheck @@ -45,19 +45,13 @@ 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_dir="${HOME}/cobolcheck" + mkdir -p "${output_dir}" output_path="${output_dir}/cobolcheck${ext}" download_url="$(get_download_url)" curl "${curlopts[@]}" --output "${output_path}" "${download_url}" chmod +x "${output_path}" + echo "Cobolcheck has been downloaded to ${output_path}" } main diff --git a/exercises/practice/rna-transcription/bin/fetch-cobolcheck.ps1 b/exercises/practice/rna-transcription/bin/fetch-cobolcheck.ps1 index a57f708d..9228452c 100644 --- a/exercises/practice/rna-transcription/bin/fetch-cobolcheck.ps1 +++ b/exercises/practice/rna-transcription/bin/fetch-cobolcheck.ps1 @@ -23,5 +23,5 @@ Function Get-DownloadUrl { } $downloadUrl = Get-DownloadUrl -$outputFile = Join-Path -Path $PSScriptRoot -ChildPath "cobolcheck.exe" +$outputFile = Join-Path -Path "${HOME}" "cobolcheck" "cobolcheck.exe" Invoke-WebRequest -Uri $downloadUrl -OutFile $outputFile @requestOpts diff --git a/exercises/practice/rna-transcription/test.ps1 b/exercises/practice/rna-transcription/test.ps1 index b54fdc61..7a2bb33b 100644 --- a/exercises/practice/rna-transcription/test.ps1 +++ b/exercises/practice/rna-transcription/test.ps1 @@ -1,13 +1,11 @@ $slug=Split-Path $PSScriptRoot -Leaf -$cobolcheck = "$PSScriptRoot\bin\cobolcheck.exe" -$cobolcheckCmd = Get-Command "cobolcheck.exe" -ErrorAction SilentlyContinue +$cobolcheck = Join-Path -Path "${HOME}" "cobolcheck" "cobolcheck.exe" -if ($cobolcheckCmd) { - $cobolcheck = $cobolcheckCmd.Path - Write-Output "Found cobolcheck, using $cobolcheck" -} elseif (![System.IO.File]::Exists("$cobolcheck")){ +if (![System.IO.File]::Exists("$cobolcheck")){ + $fetchCobolcheckPath = Join-Path -Path "${PSScriptRoot}" "bin" "fetch-cobolcheck.ps1" + echo $fetchCobolcheckPath Write-Output "Cobolcheck not found. Trying to fetch it." - & "$PSScriptRoot\bin\fetch-cobolcheck.ps1" + & "${fetchCobolcheckPath}" } Write-Output "Run cobolcheck." diff --git a/exercises/practice/rna-transcription/test.sh b/exercises/practice/rna-transcription/test.sh index ed4a27a1..7b4a9da0 100755 --- a/exercises/practice/rna-transcription/test.sh +++ b/exercises/practice/rna-transcription/test.sh @@ -1,13 +1,9 @@ #!/usr/bin/env bash SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )/ SLUG=${1:-$(basename "${SCRIPT_DIR}")} -COBOLCHECK=./bin/cobolcheck +COBOLCHECK="${HOME}/cobolcheck/cobolcheck" -WHICH_COBOLCHECK=$(which cobolcheck) -if [[ $? -eq 0 ]] ; then - echo "Found cobolcheck, using $COBOLCHECK" - COBOLCHECK=$WHICH_COBOLCHECK -elif [ ! -f $SCRIPT_DIR/bin/cobolcheck ]; then +if [ ! -f "${COBOLCHECK}" ]; then echo "Cobolcheck not found, try to fetch it." cd $SCRIPT_DIR/bin/ bash fetch-cobolcheck diff --git a/exercises/practice/robot-simulator/bin/fetch-cobolcheck b/exercises/practice/robot-simulator/bin/fetch-cobolcheck index 0b668734..b3d4adb1 100755 --- a/exercises/practice/robot-simulator/bin/fetch-cobolcheck +++ b/exercises/practice/robot-simulator/bin/fetch-cobolcheck @@ -45,19 +45,13 @@ 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_dir="${HOME}/cobolcheck" + mkdir -p "${output_dir}" output_path="${output_dir}/cobolcheck${ext}" download_url="$(get_download_url)" curl "${curlopts[@]}" --output "${output_path}" "${download_url}" chmod +x "${output_path}" + echo "Cobolcheck has been downloaded to ${output_path}" } main diff --git a/exercises/practice/robot-simulator/bin/fetch-cobolcheck.ps1 b/exercises/practice/robot-simulator/bin/fetch-cobolcheck.ps1 index a57f708d..9228452c 100644 --- a/exercises/practice/robot-simulator/bin/fetch-cobolcheck.ps1 +++ b/exercises/practice/robot-simulator/bin/fetch-cobolcheck.ps1 @@ -23,5 +23,5 @@ Function Get-DownloadUrl { } $downloadUrl = Get-DownloadUrl -$outputFile = Join-Path -Path $PSScriptRoot -ChildPath "cobolcheck.exe" +$outputFile = Join-Path -Path "${HOME}" "cobolcheck" "cobolcheck.exe" Invoke-WebRequest -Uri $downloadUrl -OutFile $outputFile @requestOpts diff --git a/exercises/practice/robot-simulator/test.ps1 b/exercises/practice/robot-simulator/test.ps1 index ccfa530a..7a2bb33b 100644 --- a/exercises/practice/robot-simulator/test.ps1 +++ b/exercises/practice/robot-simulator/test.ps1 @@ -1,14 +1,17 @@ $slug=Split-Path $PSScriptRoot -Leaf +$cobolcheck = Join-Path -Path "${HOME}" "cobolcheck" "cobolcheck.exe" -if (![System.IO.File]::Exists("$PSScriptRoot\bin\cobolcheck.exe")){ +if (![System.IO.File]::Exists("$cobolcheck")){ + $fetchCobolcheckPath = Join-Path -Path "${PSScriptRoot}" "bin" "fetch-cobolcheck.ps1" + echo $fetchCobolcheckPath Write-Output "Cobolcheck not found. Trying to fetch it." - & "$PSScriptRoot\bin\fetch-cobolcheck.ps1" + & "${fetchCobolcheckPath}" } Write-Output "Run cobolcheck." Set-Location $PSScriptRoot -Invoke-Expression "bin\cobolcheck.exe -p $slug" +Invoke-Expression "$cobolcheck -p $slug" Invoke-Expression "cobc -xj test.cob" if ($Lastexitcode -ne 0) { diff --git a/exercises/practice/robot-simulator/test.sh b/exercises/practice/robot-simulator/test.sh index ed4a27a1..7b4a9da0 100755 --- a/exercises/practice/robot-simulator/test.sh +++ b/exercises/practice/robot-simulator/test.sh @@ -1,13 +1,9 @@ #!/usr/bin/env bash SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )/ SLUG=${1:-$(basename "${SCRIPT_DIR}")} -COBOLCHECK=./bin/cobolcheck +COBOLCHECK="${HOME}/cobolcheck/cobolcheck" -WHICH_COBOLCHECK=$(which cobolcheck) -if [[ $? -eq 0 ]] ; then - echo "Found cobolcheck, using $COBOLCHECK" - COBOLCHECK=$WHICH_COBOLCHECK -elif [ ! -f $SCRIPT_DIR/bin/cobolcheck ]; then +if [ ! -f "${COBOLCHECK}" ]; then echo "Cobolcheck not found, try to fetch it." cd $SCRIPT_DIR/bin/ bash fetch-cobolcheck diff --git a/exercises/practice/roman-numerals/bin/fetch-cobolcheck b/exercises/practice/roman-numerals/bin/fetch-cobolcheck index 0b668734..b3d4adb1 100755 --- a/exercises/practice/roman-numerals/bin/fetch-cobolcheck +++ b/exercises/practice/roman-numerals/bin/fetch-cobolcheck @@ -45,19 +45,13 @@ 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_dir="${HOME}/cobolcheck" + mkdir -p "${output_dir}" output_path="${output_dir}/cobolcheck${ext}" download_url="$(get_download_url)" curl "${curlopts[@]}" --output "${output_path}" "${download_url}" chmod +x "${output_path}" + echo "Cobolcheck has been downloaded to ${output_path}" } main diff --git a/exercises/practice/roman-numerals/bin/fetch-cobolcheck.ps1 b/exercises/practice/roman-numerals/bin/fetch-cobolcheck.ps1 index a57f708d..9228452c 100644 --- a/exercises/practice/roman-numerals/bin/fetch-cobolcheck.ps1 +++ b/exercises/practice/roman-numerals/bin/fetch-cobolcheck.ps1 @@ -23,5 +23,5 @@ Function Get-DownloadUrl { } $downloadUrl = Get-DownloadUrl -$outputFile = Join-Path -Path $PSScriptRoot -ChildPath "cobolcheck.exe" +$outputFile = Join-Path -Path "${HOME}" "cobolcheck" "cobolcheck.exe" Invoke-WebRequest -Uri $downloadUrl -OutFile $outputFile @requestOpts diff --git a/exercises/practice/roman-numerals/test.ps1 b/exercises/practice/roman-numerals/test.ps1 index b54fdc61..7a2bb33b 100644 --- a/exercises/practice/roman-numerals/test.ps1 +++ b/exercises/practice/roman-numerals/test.ps1 @@ -1,13 +1,11 @@ $slug=Split-Path $PSScriptRoot -Leaf -$cobolcheck = "$PSScriptRoot\bin\cobolcheck.exe" -$cobolcheckCmd = Get-Command "cobolcheck.exe" -ErrorAction SilentlyContinue +$cobolcheck = Join-Path -Path "${HOME}" "cobolcheck" "cobolcheck.exe" -if ($cobolcheckCmd) { - $cobolcheck = $cobolcheckCmd.Path - Write-Output "Found cobolcheck, using $cobolcheck" -} elseif (![System.IO.File]::Exists("$cobolcheck")){ +if (![System.IO.File]::Exists("$cobolcheck")){ + $fetchCobolcheckPath = Join-Path -Path "${PSScriptRoot}" "bin" "fetch-cobolcheck.ps1" + echo $fetchCobolcheckPath Write-Output "Cobolcheck not found. Trying to fetch it." - & "$PSScriptRoot\bin\fetch-cobolcheck.ps1" + & "${fetchCobolcheckPath}" } Write-Output "Run cobolcheck." diff --git a/exercises/practice/roman-numerals/test.sh b/exercises/practice/roman-numerals/test.sh index ed4a27a1..7b4a9da0 100755 --- a/exercises/practice/roman-numerals/test.sh +++ b/exercises/practice/roman-numerals/test.sh @@ -1,13 +1,9 @@ #!/usr/bin/env bash SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )/ SLUG=${1:-$(basename "${SCRIPT_DIR}")} -COBOLCHECK=./bin/cobolcheck +COBOLCHECK="${HOME}/cobolcheck/cobolcheck" -WHICH_COBOLCHECK=$(which cobolcheck) -if [[ $? -eq 0 ]] ; then - echo "Found cobolcheck, using $COBOLCHECK" - COBOLCHECK=$WHICH_COBOLCHECK -elif [ ! -f $SCRIPT_DIR/bin/cobolcheck ]; then +if [ ! -f "${COBOLCHECK}" ]; then echo "Cobolcheck not found, try to fetch it." cd $SCRIPT_DIR/bin/ bash fetch-cobolcheck diff --git a/exercises/practice/rotational-cipher/bin/fetch-cobolcheck b/exercises/practice/rotational-cipher/bin/fetch-cobolcheck index 0b668734..b3d4adb1 100755 --- a/exercises/practice/rotational-cipher/bin/fetch-cobolcheck +++ b/exercises/practice/rotational-cipher/bin/fetch-cobolcheck @@ -45,19 +45,13 @@ 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_dir="${HOME}/cobolcheck" + mkdir -p "${output_dir}" output_path="${output_dir}/cobolcheck${ext}" download_url="$(get_download_url)" curl "${curlopts[@]}" --output "${output_path}" "${download_url}" chmod +x "${output_path}" + echo "Cobolcheck has been downloaded to ${output_path}" } main diff --git a/exercises/practice/rotational-cipher/bin/fetch-cobolcheck.ps1 b/exercises/practice/rotational-cipher/bin/fetch-cobolcheck.ps1 index a57f708d..9228452c 100644 --- a/exercises/practice/rotational-cipher/bin/fetch-cobolcheck.ps1 +++ b/exercises/practice/rotational-cipher/bin/fetch-cobolcheck.ps1 @@ -23,5 +23,5 @@ Function Get-DownloadUrl { } $downloadUrl = Get-DownloadUrl -$outputFile = Join-Path -Path $PSScriptRoot -ChildPath "cobolcheck.exe" +$outputFile = Join-Path -Path "${HOME}" "cobolcheck" "cobolcheck.exe" Invoke-WebRequest -Uri $downloadUrl -OutFile $outputFile @requestOpts diff --git a/exercises/practice/rotational-cipher/test.ps1 b/exercises/practice/rotational-cipher/test.ps1 index b54fdc61..7a2bb33b 100644 --- a/exercises/practice/rotational-cipher/test.ps1 +++ b/exercises/practice/rotational-cipher/test.ps1 @@ -1,13 +1,11 @@ $slug=Split-Path $PSScriptRoot -Leaf -$cobolcheck = "$PSScriptRoot\bin\cobolcheck.exe" -$cobolcheckCmd = Get-Command "cobolcheck.exe" -ErrorAction SilentlyContinue +$cobolcheck = Join-Path -Path "${HOME}" "cobolcheck" "cobolcheck.exe" -if ($cobolcheckCmd) { - $cobolcheck = $cobolcheckCmd.Path - Write-Output "Found cobolcheck, using $cobolcheck" -} elseif (![System.IO.File]::Exists("$cobolcheck")){ +if (![System.IO.File]::Exists("$cobolcheck")){ + $fetchCobolcheckPath = Join-Path -Path "${PSScriptRoot}" "bin" "fetch-cobolcheck.ps1" + echo $fetchCobolcheckPath Write-Output "Cobolcheck not found. Trying to fetch it." - & "$PSScriptRoot\bin\fetch-cobolcheck.ps1" + & "${fetchCobolcheckPath}" } Write-Output "Run cobolcheck." diff --git a/exercises/practice/rotational-cipher/test.sh b/exercises/practice/rotational-cipher/test.sh index ed4a27a1..7b4a9da0 100755 --- a/exercises/practice/rotational-cipher/test.sh +++ b/exercises/practice/rotational-cipher/test.sh @@ -1,13 +1,9 @@ #!/usr/bin/env bash SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )/ SLUG=${1:-$(basename "${SCRIPT_DIR}")} -COBOLCHECK=./bin/cobolcheck +COBOLCHECK="${HOME}/cobolcheck/cobolcheck" -WHICH_COBOLCHECK=$(which cobolcheck) -if [[ $? -eq 0 ]] ; then - echo "Found cobolcheck, using $COBOLCHECK" - COBOLCHECK=$WHICH_COBOLCHECK -elif [ ! -f $SCRIPT_DIR/bin/cobolcheck ]; then +if [ ! -f "${COBOLCHECK}" ]; then echo "Cobolcheck not found, try to fetch it." cd $SCRIPT_DIR/bin/ bash fetch-cobolcheck diff --git a/exercises/practice/scrabble-score/bin/fetch-cobolcheck b/exercises/practice/scrabble-score/bin/fetch-cobolcheck index 0b668734..b3d4adb1 100644 --- a/exercises/practice/scrabble-score/bin/fetch-cobolcheck +++ b/exercises/practice/scrabble-score/bin/fetch-cobolcheck @@ -45,19 +45,13 @@ 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_dir="${HOME}/cobolcheck" + mkdir -p "${output_dir}" output_path="${output_dir}/cobolcheck${ext}" download_url="$(get_download_url)" curl "${curlopts[@]}" --output "${output_path}" "${download_url}" chmod +x "${output_path}" + echo "Cobolcheck has been downloaded to ${output_path}" } main diff --git a/exercises/practice/scrabble-score/bin/fetch-cobolcheck.ps1 b/exercises/practice/scrabble-score/bin/fetch-cobolcheck.ps1 index a57f708d..9228452c 100644 --- a/exercises/practice/scrabble-score/bin/fetch-cobolcheck.ps1 +++ b/exercises/practice/scrabble-score/bin/fetch-cobolcheck.ps1 @@ -23,5 +23,5 @@ Function Get-DownloadUrl { } $downloadUrl = Get-DownloadUrl -$outputFile = Join-Path -Path $PSScriptRoot -ChildPath "cobolcheck.exe" +$outputFile = Join-Path -Path "${HOME}" "cobolcheck" "cobolcheck.exe" Invoke-WebRequest -Uri $downloadUrl -OutFile $outputFile @requestOpts diff --git a/exercises/practice/scrabble-score/test.ps1 b/exercises/practice/scrabble-score/test.ps1 index b54fdc61..7a2bb33b 100644 --- a/exercises/practice/scrabble-score/test.ps1 +++ b/exercises/practice/scrabble-score/test.ps1 @@ -1,13 +1,11 @@ $slug=Split-Path $PSScriptRoot -Leaf -$cobolcheck = "$PSScriptRoot\bin\cobolcheck.exe" -$cobolcheckCmd = Get-Command "cobolcheck.exe" -ErrorAction SilentlyContinue +$cobolcheck = Join-Path -Path "${HOME}" "cobolcheck" "cobolcheck.exe" -if ($cobolcheckCmd) { - $cobolcheck = $cobolcheckCmd.Path - Write-Output "Found cobolcheck, using $cobolcheck" -} elseif (![System.IO.File]::Exists("$cobolcheck")){ +if (![System.IO.File]::Exists("$cobolcheck")){ + $fetchCobolcheckPath = Join-Path -Path "${PSScriptRoot}" "bin" "fetch-cobolcheck.ps1" + echo $fetchCobolcheckPath Write-Output "Cobolcheck not found. Trying to fetch it." - & "$PSScriptRoot\bin\fetch-cobolcheck.ps1" + & "${fetchCobolcheckPath}" } Write-Output "Run cobolcheck." diff --git a/exercises/practice/scrabble-score/test.sh b/exercises/practice/scrabble-score/test.sh index ed4a27a1..7b4a9da0 100755 --- a/exercises/practice/scrabble-score/test.sh +++ b/exercises/practice/scrabble-score/test.sh @@ -1,13 +1,9 @@ #!/usr/bin/env bash SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )/ SLUG=${1:-$(basename "${SCRIPT_DIR}")} -COBOLCHECK=./bin/cobolcheck +COBOLCHECK="${HOME}/cobolcheck/cobolcheck" -WHICH_COBOLCHECK=$(which cobolcheck) -if [[ $? -eq 0 ]] ; then - echo "Found cobolcheck, using $COBOLCHECK" - COBOLCHECK=$WHICH_COBOLCHECK -elif [ ! -f $SCRIPT_DIR/bin/cobolcheck ]; then +if [ ! -f "${COBOLCHECK}" ]; then echo "Cobolcheck not found, try to fetch it." cd $SCRIPT_DIR/bin/ bash fetch-cobolcheck diff --git a/exercises/practice/secret-handshake/bin/fetch-cobolcheck b/exercises/practice/secret-handshake/bin/fetch-cobolcheck index 0b668734..b3d4adb1 100755 --- a/exercises/practice/secret-handshake/bin/fetch-cobolcheck +++ b/exercises/practice/secret-handshake/bin/fetch-cobolcheck @@ -45,19 +45,13 @@ 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_dir="${HOME}/cobolcheck" + mkdir -p "${output_dir}" output_path="${output_dir}/cobolcheck${ext}" download_url="$(get_download_url)" curl "${curlopts[@]}" --output "${output_path}" "${download_url}" chmod +x "${output_path}" + echo "Cobolcheck has been downloaded to ${output_path}" } main diff --git a/exercises/practice/secret-handshake/bin/fetch-cobolcheck.ps1 b/exercises/practice/secret-handshake/bin/fetch-cobolcheck.ps1 index a57f708d..9228452c 100644 --- a/exercises/practice/secret-handshake/bin/fetch-cobolcheck.ps1 +++ b/exercises/practice/secret-handshake/bin/fetch-cobolcheck.ps1 @@ -23,5 +23,5 @@ Function Get-DownloadUrl { } $downloadUrl = Get-DownloadUrl -$outputFile = Join-Path -Path $PSScriptRoot -ChildPath "cobolcheck.exe" +$outputFile = Join-Path -Path "${HOME}" "cobolcheck" "cobolcheck.exe" Invoke-WebRequest -Uri $downloadUrl -OutFile $outputFile @requestOpts diff --git a/exercises/practice/secret-handshake/test.ps1 b/exercises/practice/secret-handshake/test.ps1 index ccfa530a..7a2bb33b 100644 --- a/exercises/practice/secret-handshake/test.ps1 +++ b/exercises/practice/secret-handshake/test.ps1 @@ -1,14 +1,17 @@ $slug=Split-Path $PSScriptRoot -Leaf +$cobolcheck = Join-Path -Path "${HOME}" "cobolcheck" "cobolcheck.exe" -if (![System.IO.File]::Exists("$PSScriptRoot\bin\cobolcheck.exe")){ +if (![System.IO.File]::Exists("$cobolcheck")){ + $fetchCobolcheckPath = Join-Path -Path "${PSScriptRoot}" "bin" "fetch-cobolcheck.ps1" + echo $fetchCobolcheckPath Write-Output "Cobolcheck not found. Trying to fetch it." - & "$PSScriptRoot\bin\fetch-cobolcheck.ps1" + & "${fetchCobolcheckPath}" } Write-Output "Run cobolcheck." Set-Location $PSScriptRoot -Invoke-Expression "bin\cobolcheck.exe -p $slug" +Invoke-Expression "$cobolcheck -p $slug" Invoke-Expression "cobc -xj test.cob" if ($Lastexitcode -ne 0) { diff --git a/exercises/practice/secret-handshake/test.sh b/exercises/practice/secret-handshake/test.sh index ed4a27a1..7b4a9da0 100755 --- a/exercises/practice/secret-handshake/test.sh +++ b/exercises/practice/secret-handshake/test.sh @@ -1,13 +1,9 @@ #!/usr/bin/env bash SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )/ SLUG=${1:-$(basename "${SCRIPT_DIR}")} -COBOLCHECK=./bin/cobolcheck +COBOLCHECK="${HOME}/cobolcheck/cobolcheck" -WHICH_COBOLCHECK=$(which cobolcheck) -if [[ $? -eq 0 ]] ; then - echo "Found cobolcheck, using $COBOLCHECK" - COBOLCHECK=$WHICH_COBOLCHECK -elif [ ! -f $SCRIPT_DIR/bin/cobolcheck ]; then +if [ ! -f "${COBOLCHECK}" ]; then echo "Cobolcheck not found, try to fetch it." cd $SCRIPT_DIR/bin/ bash fetch-cobolcheck diff --git a/exercises/practice/sieve/bin/fetch-cobolcheck b/exercises/practice/sieve/bin/fetch-cobolcheck index 0b668734..b3d4adb1 100755 --- a/exercises/practice/sieve/bin/fetch-cobolcheck +++ b/exercises/practice/sieve/bin/fetch-cobolcheck @@ -45,19 +45,13 @@ 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_dir="${HOME}/cobolcheck" + mkdir -p "${output_dir}" output_path="${output_dir}/cobolcheck${ext}" download_url="$(get_download_url)" curl "${curlopts[@]}" --output "${output_path}" "${download_url}" chmod +x "${output_path}" + echo "Cobolcheck has been downloaded to ${output_path}" } main diff --git a/exercises/practice/sieve/bin/fetch-cobolcheck.ps1 b/exercises/practice/sieve/bin/fetch-cobolcheck.ps1 index a57f708d..9228452c 100644 --- a/exercises/practice/sieve/bin/fetch-cobolcheck.ps1 +++ b/exercises/practice/sieve/bin/fetch-cobolcheck.ps1 @@ -23,5 +23,5 @@ Function Get-DownloadUrl { } $downloadUrl = Get-DownloadUrl -$outputFile = Join-Path -Path $PSScriptRoot -ChildPath "cobolcheck.exe" +$outputFile = Join-Path -Path "${HOME}" "cobolcheck" "cobolcheck.exe" Invoke-WebRequest -Uri $downloadUrl -OutFile $outputFile @requestOpts diff --git a/exercises/practice/sieve/test.ps1 b/exercises/practice/sieve/test.ps1 index b54fdc61..7a2bb33b 100644 --- a/exercises/practice/sieve/test.ps1 +++ b/exercises/practice/sieve/test.ps1 @@ -1,13 +1,11 @@ $slug=Split-Path $PSScriptRoot -Leaf -$cobolcheck = "$PSScriptRoot\bin\cobolcheck.exe" -$cobolcheckCmd = Get-Command "cobolcheck.exe" -ErrorAction SilentlyContinue +$cobolcheck = Join-Path -Path "${HOME}" "cobolcheck" "cobolcheck.exe" -if ($cobolcheckCmd) { - $cobolcheck = $cobolcheckCmd.Path - Write-Output "Found cobolcheck, using $cobolcheck" -} elseif (![System.IO.File]::Exists("$cobolcheck")){ +if (![System.IO.File]::Exists("$cobolcheck")){ + $fetchCobolcheckPath = Join-Path -Path "${PSScriptRoot}" "bin" "fetch-cobolcheck.ps1" + echo $fetchCobolcheckPath Write-Output "Cobolcheck not found. Trying to fetch it." - & "$PSScriptRoot\bin\fetch-cobolcheck.ps1" + & "${fetchCobolcheckPath}" } Write-Output "Run cobolcheck." diff --git a/exercises/practice/sieve/test.sh b/exercises/practice/sieve/test.sh index ed4a27a1..7b4a9da0 100755 --- a/exercises/practice/sieve/test.sh +++ b/exercises/practice/sieve/test.sh @@ -1,13 +1,9 @@ #!/usr/bin/env bash SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )/ SLUG=${1:-$(basename "${SCRIPT_DIR}")} -COBOLCHECK=./bin/cobolcheck +COBOLCHECK="${HOME}/cobolcheck/cobolcheck" -WHICH_COBOLCHECK=$(which cobolcheck) -if [[ $? -eq 0 ]] ; then - echo "Found cobolcheck, using $COBOLCHECK" - COBOLCHECK=$WHICH_COBOLCHECK -elif [ ! -f $SCRIPT_DIR/bin/cobolcheck ]; then +if [ ! -f "${COBOLCHECK}" ]; then echo "Cobolcheck not found, try to fetch it." cd $SCRIPT_DIR/bin/ bash fetch-cobolcheck diff --git a/exercises/practice/space-age/bin/fetch-cobolcheck b/exercises/practice/space-age/bin/fetch-cobolcheck index 0b668734..b3d4adb1 100755 --- a/exercises/practice/space-age/bin/fetch-cobolcheck +++ b/exercises/practice/space-age/bin/fetch-cobolcheck @@ -45,19 +45,13 @@ 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_dir="${HOME}/cobolcheck" + mkdir -p "${output_dir}" output_path="${output_dir}/cobolcheck${ext}" download_url="$(get_download_url)" curl "${curlopts[@]}" --output "${output_path}" "${download_url}" chmod +x "${output_path}" + echo "Cobolcheck has been downloaded to ${output_path}" } main diff --git a/exercises/practice/space-age/bin/fetch-cobolcheck.ps1 b/exercises/practice/space-age/bin/fetch-cobolcheck.ps1 index a57f708d..9228452c 100644 --- a/exercises/practice/space-age/bin/fetch-cobolcheck.ps1 +++ b/exercises/practice/space-age/bin/fetch-cobolcheck.ps1 @@ -23,5 +23,5 @@ Function Get-DownloadUrl { } $downloadUrl = Get-DownloadUrl -$outputFile = Join-Path -Path $PSScriptRoot -ChildPath "cobolcheck.exe" +$outputFile = Join-Path -Path "${HOME}" "cobolcheck" "cobolcheck.exe" Invoke-WebRequest -Uri $downloadUrl -OutFile $outputFile @requestOpts diff --git a/exercises/practice/space-age/test.ps1 b/exercises/practice/space-age/test.ps1 index ccfa530a..7a2bb33b 100644 --- a/exercises/practice/space-age/test.ps1 +++ b/exercises/practice/space-age/test.ps1 @@ -1,14 +1,17 @@ $slug=Split-Path $PSScriptRoot -Leaf +$cobolcheck = Join-Path -Path "${HOME}" "cobolcheck" "cobolcheck.exe" -if (![System.IO.File]::Exists("$PSScriptRoot\bin\cobolcheck.exe")){ +if (![System.IO.File]::Exists("$cobolcheck")){ + $fetchCobolcheckPath = Join-Path -Path "${PSScriptRoot}" "bin" "fetch-cobolcheck.ps1" + echo $fetchCobolcheckPath Write-Output "Cobolcheck not found. Trying to fetch it." - & "$PSScriptRoot\bin\fetch-cobolcheck.ps1" + & "${fetchCobolcheckPath}" } Write-Output "Run cobolcheck." Set-Location $PSScriptRoot -Invoke-Expression "bin\cobolcheck.exe -p $slug" +Invoke-Expression "$cobolcheck -p $slug" Invoke-Expression "cobc -xj test.cob" if ($Lastexitcode -ne 0) { diff --git a/exercises/practice/space-age/test.sh b/exercises/practice/space-age/test.sh index ed4a27a1..7b4a9da0 100755 --- a/exercises/practice/space-age/test.sh +++ b/exercises/practice/space-age/test.sh @@ -1,13 +1,9 @@ #!/usr/bin/env bash SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )/ SLUG=${1:-$(basename "${SCRIPT_DIR}")} -COBOLCHECK=./bin/cobolcheck +COBOLCHECK="${HOME}/cobolcheck/cobolcheck" -WHICH_COBOLCHECK=$(which cobolcheck) -if [[ $? -eq 0 ]] ; then - echo "Found cobolcheck, using $COBOLCHECK" - COBOLCHECK=$WHICH_COBOLCHECK -elif [ ! -f $SCRIPT_DIR/bin/cobolcheck ]; then +if [ ! -f "${COBOLCHECK}" ]; then echo "Cobolcheck not found, try to fetch it." cd $SCRIPT_DIR/bin/ bash fetch-cobolcheck diff --git a/exercises/practice/square-root/bin/fetch-cobolcheck b/exercises/practice/square-root/bin/fetch-cobolcheck index 0b668734..b3d4adb1 100755 --- a/exercises/practice/square-root/bin/fetch-cobolcheck +++ b/exercises/practice/square-root/bin/fetch-cobolcheck @@ -45,19 +45,13 @@ 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_dir="${HOME}/cobolcheck" + mkdir -p "${output_dir}" output_path="${output_dir}/cobolcheck${ext}" download_url="$(get_download_url)" curl "${curlopts[@]}" --output "${output_path}" "${download_url}" chmod +x "${output_path}" + echo "Cobolcheck has been downloaded to ${output_path}" } main diff --git a/exercises/practice/square-root/bin/fetch-cobolcheck.ps1 b/exercises/practice/square-root/bin/fetch-cobolcheck.ps1 index a57f708d..9228452c 100644 --- a/exercises/practice/square-root/bin/fetch-cobolcheck.ps1 +++ b/exercises/practice/square-root/bin/fetch-cobolcheck.ps1 @@ -23,5 +23,5 @@ Function Get-DownloadUrl { } $downloadUrl = Get-DownloadUrl -$outputFile = Join-Path -Path $PSScriptRoot -ChildPath "cobolcheck.exe" +$outputFile = Join-Path -Path "${HOME}" "cobolcheck" "cobolcheck.exe" Invoke-WebRequest -Uri $downloadUrl -OutFile $outputFile @requestOpts diff --git a/exercises/practice/square-root/test.ps1 b/exercises/practice/square-root/test.ps1 index b54fdc61..7a2bb33b 100644 --- a/exercises/practice/square-root/test.ps1 +++ b/exercises/practice/square-root/test.ps1 @@ -1,13 +1,11 @@ $slug=Split-Path $PSScriptRoot -Leaf -$cobolcheck = "$PSScriptRoot\bin\cobolcheck.exe" -$cobolcheckCmd = Get-Command "cobolcheck.exe" -ErrorAction SilentlyContinue +$cobolcheck = Join-Path -Path "${HOME}" "cobolcheck" "cobolcheck.exe" -if ($cobolcheckCmd) { - $cobolcheck = $cobolcheckCmd.Path - Write-Output "Found cobolcheck, using $cobolcheck" -} elseif (![System.IO.File]::Exists("$cobolcheck")){ +if (![System.IO.File]::Exists("$cobolcheck")){ + $fetchCobolcheckPath = Join-Path -Path "${PSScriptRoot}" "bin" "fetch-cobolcheck.ps1" + echo $fetchCobolcheckPath Write-Output "Cobolcheck not found. Trying to fetch it." - & "$PSScriptRoot\bin\fetch-cobolcheck.ps1" + & "${fetchCobolcheckPath}" } Write-Output "Run cobolcheck." diff --git a/exercises/practice/square-root/test.sh b/exercises/practice/square-root/test.sh index ed4a27a1..7b4a9da0 100755 --- a/exercises/practice/square-root/test.sh +++ b/exercises/practice/square-root/test.sh @@ -1,13 +1,9 @@ #!/usr/bin/env bash SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )/ SLUG=${1:-$(basename "${SCRIPT_DIR}")} -COBOLCHECK=./bin/cobolcheck +COBOLCHECK="${HOME}/cobolcheck/cobolcheck" -WHICH_COBOLCHECK=$(which cobolcheck) -if [[ $? -eq 0 ]] ; then - echo "Found cobolcheck, using $COBOLCHECK" - COBOLCHECK=$WHICH_COBOLCHECK -elif [ ! -f $SCRIPT_DIR/bin/cobolcheck ]; then +if [ ! -f "${COBOLCHECK}" ]; then echo "Cobolcheck not found, try to fetch it." cd $SCRIPT_DIR/bin/ bash fetch-cobolcheck diff --git a/exercises/practice/triangle/bin/fetch-cobolcheck b/exercises/practice/triangle/bin/fetch-cobolcheck index 0b668734..b3d4adb1 100644 --- a/exercises/practice/triangle/bin/fetch-cobolcheck +++ b/exercises/practice/triangle/bin/fetch-cobolcheck @@ -45,19 +45,13 @@ 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_dir="${HOME}/cobolcheck" + mkdir -p "${output_dir}" output_path="${output_dir}/cobolcheck${ext}" download_url="$(get_download_url)" curl "${curlopts[@]}" --output "${output_path}" "${download_url}" chmod +x "${output_path}" + echo "Cobolcheck has been downloaded to ${output_path}" } main diff --git a/exercises/practice/triangle/bin/fetch-cobolcheck.ps1 b/exercises/practice/triangle/bin/fetch-cobolcheck.ps1 index a57f708d..9228452c 100644 --- a/exercises/practice/triangle/bin/fetch-cobolcheck.ps1 +++ b/exercises/practice/triangle/bin/fetch-cobolcheck.ps1 @@ -23,5 +23,5 @@ Function Get-DownloadUrl { } $downloadUrl = Get-DownloadUrl -$outputFile = Join-Path -Path $PSScriptRoot -ChildPath "cobolcheck.exe" +$outputFile = Join-Path -Path "${HOME}" "cobolcheck" "cobolcheck.exe" Invoke-WebRequest -Uri $downloadUrl -OutFile $outputFile @requestOpts diff --git a/exercises/practice/triangle/test.ps1 b/exercises/practice/triangle/test.ps1 index b54fdc61..7a2bb33b 100644 --- a/exercises/practice/triangle/test.ps1 +++ b/exercises/practice/triangle/test.ps1 @@ -1,13 +1,11 @@ $slug=Split-Path $PSScriptRoot -Leaf -$cobolcheck = "$PSScriptRoot\bin\cobolcheck.exe" -$cobolcheckCmd = Get-Command "cobolcheck.exe" -ErrorAction SilentlyContinue +$cobolcheck = Join-Path -Path "${HOME}" "cobolcheck" "cobolcheck.exe" -if ($cobolcheckCmd) { - $cobolcheck = $cobolcheckCmd.Path - Write-Output "Found cobolcheck, using $cobolcheck" -} elseif (![System.IO.File]::Exists("$cobolcheck")){ +if (![System.IO.File]::Exists("$cobolcheck")){ + $fetchCobolcheckPath = Join-Path -Path "${PSScriptRoot}" "bin" "fetch-cobolcheck.ps1" + echo $fetchCobolcheckPath Write-Output "Cobolcheck not found. Trying to fetch it." - & "$PSScriptRoot\bin\fetch-cobolcheck.ps1" + & "${fetchCobolcheckPath}" } Write-Output "Run cobolcheck." diff --git a/exercises/practice/triangle/test.sh b/exercises/practice/triangle/test.sh index ed4a27a1..7b4a9da0 100755 --- a/exercises/practice/triangle/test.sh +++ b/exercises/practice/triangle/test.sh @@ -1,13 +1,9 @@ #!/usr/bin/env bash SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )/ SLUG=${1:-$(basename "${SCRIPT_DIR}")} -COBOLCHECK=./bin/cobolcheck +COBOLCHECK="${HOME}/cobolcheck/cobolcheck" -WHICH_COBOLCHECK=$(which cobolcheck) -if [[ $? -eq 0 ]] ; then - echo "Found cobolcheck, using $COBOLCHECK" - COBOLCHECK=$WHICH_COBOLCHECK -elif [ ! -f $SCRIPT_DIR/bin/cobolcheck ]; then +if [ ! -f "${COBOLCHECK}" ]; then echo "Cobolcheck not found, try to fetch it." cd $SCRIPT_DIR/bin/ bash fetch-cobolcheck diff --git a/exercises/practice/two-fer/bin/fetch-cobolcheck b/exercises/practice/two-fer/bin/fetch-cobolcheck index 0b668734..b3d4adb1 100755 --- a/exercises/practice/two-fer/bin/fetch-cobolcheck +++ b/exercises/practice/two-fer/bin/fetch-cobolcheck @@ -45,19 +45,13 @@ 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_dir="${HOME}/cobolcheck" + mkdir -p "${output_dir}" output_path="${output_dir}/cobolcheck${ext}" download_url="$(get_download_url)" curl "${curlopts[@]}" --output "${output_path}" "${download_url}" chmod +x "${output_path}" + echo "Cobolcheck has been downloaded to ${output_path}" } main diff --git a/exercises/practice/two-fer/bin/fetch-cobolcheck.ps1 b/exercises/practice/two-fer/bin/fetch-cobolcheck.ps1 index a57f708d..9228452c 100644 --- a/exercises/practice/two-fer/bin/fetch-cobolcheck.ps1 +++ b/exercises/practice/two-fer/bin/fetch-cobolcheck.ps1 @@ -23,5 +23,5 @@ Function Get-DownloadUrl { } $downloadUrl = Get-DownloadUrl -$outputFile = Join-Path -Path $PSScriptRoot -ChildPath "cobolcheck.exe" +$outputFile = Join-Path -Path "${HOME}" "cobolcheck" "cobolcheck.exe" Invoke-WebRequest -Uri $downloadUrl -OutFile $outputFile @requestOpts diff --git a/exercises/practice/two-fer/test.ps1 b/exercises/practice/two-fer/test.ps1 index b54fdc61..7a2bb33b 100644 --- a/exercises/practice/two-fer/test.ps1 +++ b/exercises/practice/two-fer/test.ps1 @@ -1,13 +1,11 @@ $slug=Split-Path $PSScriptRoot -Leaf -$cobolcheck = "$PSScriptRoot\bin\cobolcheck.exe" -$cobolcheckCmd = Get-Command "cobolcheck.exe" -ErrorAction SilentlyContinue +$cobolcheck = Join-Path -Path "${HOME}" "cobolcheck" "cobolcheck.exe" -if ($cobolcheckCmd) { - $cobolcheck = $cobolcheckCmd.Path - Write-Output "Found cobolcheck, using $cobolcheck" -} elseif (![System.IO.File]::Exists("$cobolcheck")){ +if (![System.IO.File]::Exists("$cobolcheck")){ + $fetchCobolcheckPath = Join-Path -Path "${PSScriptRoot}" "bin" "fetch-cobolcheck.ps1" + echo $fetchCobolcheckPath Write-Output "Cobolcheck not found. Trying to fetch it." - & "$PSScriptRoot\bin\fetch-cobolcheck.ps1" + & "${fetchCobolcheckPath}" } Write-Output "Run cobolcheck." diff --git a/exercises/practice/two-fer/test.sh b/exercises/practice/two-fer/test.sh index ed4a27a1..7b4a9da0 100755 --- a/exercises/practice/two-fer/test.sh +++ b/exercises/practice/two-fer/test.sh @@ -1,13 +1,9 @@ #!/usr/bin/env bash SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )/ SLUG=${1:-$(basename "${SCRIPT_DIR}")} -COBOLCHECK=./bin/cobolcheck +COBOLCHECK="${HOME}/cobolcheck/cobolcheck" -WHICH_COBOLCHECK=$(which cobolcheck) -if [[ $? -eq 0 ]] ; then - echo "Found cobolcheck, using $COBOLCHECK" - COBOLCHECK=$WHICH_COBOLCHECK -elif [ ! -f $SCRIPT_DIR/bin/cobolcheck ]; then +if [ ! -f "${COBOLCHECK}" ]; then echo "Cobolcheck not found, try to fetch it." cd $SCRIPT_DIR/bin/ bash fetch-cobolcheck diff --git a/exercises/practice/yacht/bin/fetch-cobolcheck b/exercises/practice/yacht/bin/fetch-cobolcheck index 0b668734..b3d4adb1 100755 --- a/exercises/practice/yacht/bin/fetch-cobolcheck +++ b/exercises/practice/yacht/bin/fetch-cobolcheck @@ -45,19 +45,13 @@ 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_dir="${HOME}/cobolcheck" + mkdir -p "${output_dir}" output_path="${output_dir}/cobolcheck${ext}" download_url="$(get_download_url)" curl "${curlopts[@]}" --output "${output_path}" "${download_url}" chmod +x "${output_path}" + echo "Cobolcheck has been downloaded to ${output_path}" } main diff --git a/exercises/practice/yacht/bin/fetch-cobolcheck.ps1 b/exercises/practice/yacht/bin/fetch-cobolcheck.ps1 index a57f708d..9228452c 100644 --- a/exercises/practice/yacht/bin/fetch-cobolcheck.ps1 +++ b/exercises/practice/yacht/bin/fetch-cobolcheck.ps1 @@ -23,5 +23,5 @@ Function Get-DownloadUrl { } $downloadUrl = Get-DownloadUrl -$outputFile = Join-Path -Path $PSScriptRoot -ChildPath "cobolcheck.exe" +$outputFile = Join-Path -Path "${HOME}" "cobolcheck" "cobolcheck.exe" Invoke-WebRequest -Uri $downloadUrl -OutFile $outputFile @requestOpts diff --git a/exercises/practice/yacht/test.ps1 b/exercises/practice/yacht/test.ps1 index b54fdc61..7a2bb33b 100644 --- a/exercises/practice/yacht/test.ps1 +++ b/exercises/practice/yacht/test.ps1 @@ -1,13 +1,11 @@ $slug=Split-Path $PSScriptRoot -Leaf -$cobolcheck = "$PSScriptRoot\bin\cobolcheck.exe" -$cobolcheckCmd = Get-Command "cobolcheck.exe" -ErrorAction SilentlyContinue +$cobolcheck = Join-Path -Path "${HOME}" "cobolcheck" "cobolcheck.exe" -if ($cobolcheckCmd) { - $cobolcheck = $cobolcheckCmd.Path - Write-Output "Found cobolcheck, using $cobolcheck" -} elseif (![System.IO.File]::Exists("$cobolcheck")){ +if (![System.IO.File]::Exists("$cobolcheck")){ + $fetchCobolcheckPath = Join-Path -Path "${PSScriptRoot}" "bin" "fetch-cobolcheck.ps1" + echo $fetchCobolcheckPath Write-Output "Cobolcheck not found. Trying to fetch it." - & "$PSScriptRoot\bin\fetch-cobolcheck.ps1" + & "${fetchCobolcheckPath}" } Write-Output "Run cobolcheck." diff --git a/exercises/practice/yacht/test.sh b/exercises/practice/yacht/test.sh index ed4a27a1..7b4a9da0 100755 --- a/exercises/practice/yacht/test.sh +++ b/exercises/practice/yacht/test.sh @@ -1,13 +1,9 @@ #!/usr/bin/env bash SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )/ SLUG=${1:-$(basename "${SCRIPT_DIR}")} -COBOLCHECK=./bin/cobolcheck +COBOLCHECK="${HOME}/cobolcheck/cobolcheck" -WHICH_COBOLCHECK=$(which cobolcheck) -if [[ $? -eq 0 ]] ; then - echo "Found cobolcheck, using $COBOLCHECK" - COBOLCHECK=$WHICH_COBOLCHECK -elif [ ! -f $SCRIPT_DIR/bin/cobolcheck ]; then +if [ ! -f "${COBOLCHECK}" ]; then echo "Cobolcheck not found, try to fetch it." cd $SCRIPT_DIR/bin/ bash fetch-cobolcheck From 46e596c5453b6d8b6d94424bf049e6a0487c0b8e Mon Sep 17 00:00:00 2001 From: SimaDovakin Date: Sat, 10 Aug 2024 17:55:38 +0300 Subject: [PATCH 3/4] fetch-cobolcheck-fixes: Restored the previous file permissions. --- bin/exercise_test.sh | 0 exercises/practice/acronym/test.sh | 0 exercises/practice/anagram/test.sh | 0 3 files changed, 0 insertions(+), 0 deletions(-) mode change 100755 => 100644 bin/exercise_test.sh mode change 100755 => 100644 exercises/practice/acronym/test.sh mode change 100755 => 100644 exercises/practice/anagram/test.sh diff --git a/bin/exercise_test.sh b/bin/exercise_test.sh old mode 100755 new mode 100644 diff --git a/exercises/practice/acronym/test.sh b/exercises/practice/acronym/test.sh old mode 100755 new mode 100644 diff --git a/exercises/practice/anagram/test.sh b/exercises/practice/anagram/test.sh old mode 100755 new mode 100644 From 0d2f859d012126703d225fe18211f39e555148e7 Mon Sep 17 00:00:00 2001 From: SimaDovakin Date: Tue, 13 Aug 2024 10:55:51 +0300 Subject: [PATCH 4/4] fetch-cobolcheck-fixes: Added command for the /home/simadovakin/cobolcheck/ creation in the fetch-cobolcheck,ps1 --- bin/fetch-cobolcheck.ps1 | 4 +++- exercises/practice/acronym/bin/fetch-cobolcheck.ps1 | 4 +++- exercises/practice/all-your-base/bin/fetch-cobolcheck.ps1 | 4 +++- exercises/practice/allergies/bin/fetch-cobolcheck.ps1 | 4 +++- exercises/practice/anagram/bin/fetch-cobolcheck.ps1 | 4 +++- exercises/practice/armstrong-numbers/bin/fetch-cobolcheck.ps1 | 4 +++- exercises/practice/atbash-cipher/bin/fetch-cobolcheck.ps1 | 4 +++- exercises/practice/binary-search/bin/fetch-cobolcheck.ps1 | 4 +++- exercises/practice/binary/bin/fetch-cobolcheck.ps1 | 4 +++- exercises/practice/bob/bin/fetch-cobolcheck.ps1 | 4 +++- exercises/practice/circular-buffer/bin/fetch-cobolcheck.ps1 | 4 +++- .../practice/collatz-conjecture/bin/fetch-cobolcheck.ps1 | 4 +++- exercises/practice/complex-numbers/bin/fetch-cobolcheck.ps1 | 4 +++- exercises/practice/darts/bin/fetch-cobolcheck.ps1 | 4 +++- exercises/practice/diamond/bin/fetch-cobolcheck.ps1 | 4 +++- .../practice/difference-of-squares/bin/fetch-cobolcheck.ps1 | 4 +++- exercises/practice/eliuds-eggs/bin/fetch-cobolcheck.ps1 | 4 +++- exercises/practice/grade-school/bin/fetch-cobolcheck.ps1 | 4 +++- exercises/practice/hamming/bin/fetch-cobolcheck.ps1 | 4 +++- exercises/practice/hello-world/bin/fetch-cobolcheck.ps1 | 4 +++- exercises/practice/high-scores/bin/fetch-cobolcheck.ps1 | 4 +++- exercises/practice/isogram/bin/fetch-cobolcheck.ps1 | 4 +++- exercises/practice/knapsack/bin/fetch-cobolcheck.ps1 | 4 +++- exercises/practice/leap/bin/fetch-cobolcheck.ps1 | 4 +++- exercises/practice/luhn/bin/fetch-cobolcheck.ps1 | 4 +++- exercises/practice/matching-brackets/bin/fetch-cobolcheck.ps1 | 4 +++- exercises/practice/meetup/bin/fetch-cobolcheck.ps1 | 4 +++- exercises/practice/nucleotide-count/bin/fetch-cobolcheck.ps1 | 4 +++- exercises/practice/pangram/bin/fetch-cobolcheck.ps1 | 4 +++- exercises/practice/pascals-triangle/bin/fetch-cobolcheck.ps1 | 4 +++- exercises/practice/pig-latin/bin/fetch-cobolcheck.ps1 | 4 +++- .../practice/protein-translation/bin/fetch-cobolcheck.ps1 | 4 +++- exercises/practice/queen-attack/bin/fetch-cobolcheck.ps1 | 4 +++- exercises/practice/raindrops/bin/fetch-cobolcheck.ps1 | 4 +++- exercises/practice/reverse-string/bin/fetch-cobolcheck.ps1 | 4 +++- exercises/practice/rna-transcription/bin/fetch-cobolcheck.ps1 | 4 +++- exercises/practice/robot-simulator/bin/fetch-cobolcheck.ps1 | 4 +++- exercises/practice/roman-numerals/bin/fetch-cobolcheck.ps1 | 4 +++- exercises/practice/rotational-cipher/bin/fetch-cobolcheck.ps1 | 4 +++- exercises/practice/scrabble-score/bin/fetch-cobolcheck.ps1 | 4 +++- exercises/practice/secret-handshake/bin/fetch-cobolcheck.ps1 | 4 +++- exercises/practice/sieve/bin/fetch-cobolcheck.ps1 | 4 +++- exercises/practice/space-age/bin/fetch-cobolcheck.ps1 | 4 +++- exercises/practice/square-root/bin/fetch-cobolcheck.ps1 | 4 +++- exercises/practice/triangle/bin/fetch-cobolcheck.ps1 | 4 +++- exercises/practice/two-fer/bin/fetch-cobolcheck.ps1 | 4 +++- exercises/practice/yacht/bin/fetch-cobolcheck.ps1 | 4 +++- 47 files changed, 141 insertions(+), 47 deletions(-) diff --git a/bin/fetch-cobolcheck.ps1 b/bin/fetch-cobolcheck.ps1 index 9228452c..ed32d5ad 100644 --- a/bin/fetch-cobolcheck.ps1 +++ b/bin/fetch-cobolcheck.ps1 @@ -23,5 +23,7 @@ Function Get-DownloadUrl { } $downloadUrl = Get-DownloadUrl -$outputFile = Join-Path -Path "${HOME}" "cobolcheck" "cobolcheck.exe" +$outputDir = Join-Path -Path "${HOME}" "cobolcheck" +New-Item -Path "${outputDir}" -ItemType "directory" +$outputFile = Join-Path -Path "${outputDir}" "cobolcheck.exe" Invoke-WebRequest -Uri $downloadUrl -OutFile $outputFile @requestOpts diff --git a/exercises/practice/acronym/bin/fetch-cobolcheck.ps1 b/exercises/practice/acronym/bin/fetch-cobolcheck.ps1 index 9228452c..ed32d5ad 100644 --- a/exercises/practice/acronym/bin/fetch-cobolcheck.ps1 +++ b/exercises/practice/acronym/bin/fetch-cobolcheck.ps1 @@ -23,5 +23,7 @@ Function Get-DownloadUrl { } $downloadUrl = Get-DownloadUrl -$outputFile = Join-Path -Path "${HOME}" "cobolcheck" "cobolcheck.exe" +$outputDir = Join-Path -Path "${HOME}" "cobolcheck" +New-Item -Path "${outputDir}" -ItemType "directory" +$outputFile = Join-Path -Path "${outputDir}" "cobolcheck.exe" Invoke-WebRequest -Uri $downloadUrl -OutFile $outputFile @requestOpts diff --git a/exercises/practice/all-your-base/bin/fetch-cobolcheck.ps1 b/exercises/practice/all-your-base/bin/fetch-cobolcheck.ps1 index 9228452c..ed32d5ad 100644 --- a/exercises/practice/all-your-base/bin/fetch-cobolcheck.ps1 +++ b/exercises/practice/all-your-base/bin/fetch-cobolcheck.ps1 @@ -23,5 +23,7 @@ Function Get-DownloadUrl { } $downloadUrl = Get-DownloadUrl -$outputFile = Join-Path -Path "${HOME}" "cobolcheck" "cobolcheck.exe" +$outputDir = Join-Path -Path "${HOME}" "cobolcheck" +New-Item -Path "${outputDir}" -ItemType "directory" +$outputFile = Join-Path -Path "${outputDir}" "cobolcheck.exe" Invoke-WebRequest -Uri $downloadUrl -OutFile $outputFile @requestOpts diff --git a/exercises/practice/allergies/bin/fetch-cobolcheck.ps1 b/exercises/practice/allergies/bin/fetch-cobolcheck.ps1 index 9228452c..ed32d5ad 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 "${HOME}" "cobolcheck" "cobolcheck.exe" +$outputDir = Join-Path -Path "${HOME}" "cobolcheck" +New-Item -Path "${outputDir}" -ItemType "directory" +$outputFile = Join-Path -Path "${outputDir}" "cobolcheck.exe" Invoke-WebRequest -Uri $downloadUrl -OutFile $outputFile @requestOpts diff --git a/exercises/practice/anagram/bin/fetch-cobolcheck.ps1 b/exercises/practice/anagram/bin/fetch-cobolcheck.ps1 index 9228452c..ed32d5ad 100644 --- a/exercises/practice/anagram/bin/fetch-cobolcheck.ps1 +++ b/exercises/practice/anagram/bin/fetch-cobolcheck.ps1 @@ -23,5 +23,7 @@ Function Get-DownloadUrl { } $downloadUrl = Get-DownloadUrl -$outputFile = Join-Path -Path "${HOME}" "cobolcheck" "cobolcheck.exe" +$outputDir = Join-Path -Path "${HOME}" "cobolcheck" +New-Item -Path "${outputDir}" -ItemType "directory" +$outputFile = Join-Path -Path "${outputDir}" "cobolcheck.exe" Invoke-WebRequest -Uri $downloadUrl -OutFile $outputFile @requestOpts diff --git a/exercises/practice/armstrong-numbers/bin/fetch-cobolcheck.ps1 b/exercises/practice/armstrong-numbers/bin/fetch-cobolcheck.ps1 index 9228452c..ed32d5ad 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 "${HOME}" "cobolcheck" "cobolcheck.exe" +$outputDir = Join-Path -Path "${HOME}" "cobolcheck" +New-Item -Path "${outputDir}" -ItemType "directory" +$outputFile = Join-Path -Path "${outputDir}" "cobolcheck.exe" Invoke-WebRequest -Uri $downloadUrl -OutFile $outputFile @requestOpts diff --git a/exercises/practice/atbash-cipher/bin/fetch-cobolcheck.ps1 b/exercises/practice/atbash-cipher/bin/fetch-cobolcheck.ps1 index 9228452c..ed32d5ad 100644 --- a/exercises/practice/atbash-cipher/bin/fetch-cobolcheck.ps1 +++ b/exercises/practice/atbash-cipher/bin/fetch-cobolcheck.ps1 @@ -23,5 +23,7 @@ Function Get-DownloadUrl { } $downloadUrl = Get-DownloadUrl -$outputFile = Join-Path -Path "${HOME}" "cobolcheck" "cobolcheck.exe" +$outputDir = Join-Path -Path "${HOME}" "cobolcheck" +New-Item -Path "${outputDir}" -ItemType "directory" +$outputFile = Join-Path -Path "${outputDir}" "cobolcheck.exe" Invoke-WebRequest -Uri $downloadUrl -OutFile $outputFile @requestOpts diff --git a/exercises/practice/binary-search/bin/fetch-cobolcheck.ps1 b/exercises/practice/binary-search/bin/fetch-cobolcheck.ps1 index 9228452c..ed32d5ad 100644 --- a/exercises/practice/binary-search/bin/fetch-cobolcheck.ps1 +++ b/exercises/practice/binary-search/bin/fetch-cobolcheck.ps1 @@ -23,5 +23,7 @@ Function Get-DownloadUrl { } $downloadUrl = Get-DownloadUrl -$outputFile = Join-Path -Path "${HOME}" "cobolcheck" "cobolcheck.exe" +$outputDir = Join-Path -Path "${HOME}" "cobolcheck" +New-Item -Path "${outputDir}" -ItemType "directory" +$outputFile = Join-Path -Path "${outputDir}" "cobolcheck.exe" Invoke-WebRequest -Uri $downloadUrl -OutFile $outputFile @requestOpts diff --git a/exercises/practice/binary/bin/fetch-cobolcheck.ps1 b/exercises/practice/binary/bin/fetch-cobolcheck.ps1 index 9228452c..ed32d5ad 100644 --- a/exercises/practice/binary/bin/fetch-cobolcheck.ps1 +++ b/exercises/practice/binary/bin/fetch-cobolcheck.ps1 @@ -23,5 +23,7 @@ Function Get-DownloadUrl { } $downloadUrl = Get-DownloadUrl -$outputFile = Join-Path -Path "${HOME}" "cobolcheck" "cobolcheck.exe" +$outputDir = Join-Path -Path "${HOME}" "cobolcheck" +New-Item -Path "${outputDir}" -ItemType "directory" +$outputFile = Join-Path -Path "${outputDir}" "cobolcheck.exe" Invoke-WebRequest -Uri $downloadUrl -OutFile $outputFile @requestOpts diff --git a/exercises/practice/bob/bin/fetch-cobolcheck.ps1 b/exercises/practice/bob/bin/fetch-cobolcheck.ps1 index 9228452c..ed32d5ad 100644 --- a/exercises/practice/bob/bin/fetch-cobolcheck.ps1 +++ b/exercises/practice/bob/bin/fetch-cobolcheck.ps1 @@ -23,5 +23,7 @@ Function Get-DownloadUrl { } $downloadUrl = Get-DownloadUrl -$outputFile = Join-Path -Path "${HOME}" "cobolcheck" "cobolcheck.exe" +$outputDir = Join-Path -Path "${HOME}" "cobolcheck" +New-Item -Path "${outputDir}" -ItemType "directory" +$outputFile = Join-Path -Path "${outputDir}" "cobolcheck.exe" Invoke-WebRequest -Uri $downloadUrl -OutFile $outputFile @requestOpts diff --git a/exercises/practice/circular-buffer/bin/fetch-cobolcheck.ps1 b/exercises/practice/circular-buffer/bin/fetch-cobolcheck.ps1 index 9228452c..ed32d5ad 100644 --- a/exercises/practice/circular-buffer/bin/fetch-cobolcheck.ps1 +++ b/exercises/practice/circular-buffer/bin/fetch-cobolcheck.ps1 @@ -23,5 +23,7 @@ Function Get-DownloadUrl { } $downloadUrl = Get-DownloadUrl -$outputFile = Join-Path -Path "${HOME}" "cobolcheck" "cobolcheck.exe" +$outputDir = Join-Path -Path "${HOME}" "cobolcheck" +New-Item -Path "${outputDir}" -ItemType "directory" +$outputFile = Join-Path -Path "${outputDir}" "cobolcheck.exe" Invoke-WebRequest -Uri $downloadUrl -OutFile $outputFile @requestOpts diff --git a/exercises/practice/collatz-conjecture/bin/fetch-cobolcheck.ps1 b/exercises/practice/collatz-conjecture/bin/fetch-cobolcheck.ps1 index 9228452c..ed32d5ad 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 "${HOME}" "cobolcheck" "cobolcheck.exe" +$outputDir = Join-Path -Path "${HOME}" "cobolcheck" +New-Item -Path "${outputDir}" -ItemType "directory" +$outputFile = Join-Path -Path "${outputDir}" "cobolcheck.exe" Invoke-WebRequest -Uri $downloadUrl -OutFile $outputFile @requestOpts diff --git a/exercises/practice/complex-numbers/bin/fetch-cobolcheck.ps1 b/exercises/practice/complex-numbers/bin/fetch-cobolcheck.ps1 index 9228452c..ed32d5ad 100644 --- a/exercises/practice/complex-numbers/bin/fetch-cobolcheck.ps1 +++ b/exercises/practice/complex-numbers/bin/fetch-cobolcheck.ps1 @@ -23,5 +23,7 @@ Function Get-DownloadUrl { } $downloadUrl = Get-DownloadUrl -$outputFile = Join-Path -Path "${HOME}" "cobolcheck" "cobolcheck.exe" +$outputDir = Join-Path -Path "${HOME}" "cobolcheck" +New-Item -Path "${outputDir}" -ItemType "directory" +$outputFile = Join-Path -Path "${outputDir}" "cobolcheck.exe" Invoke-WebRequest -Uri $downloadUrl -OutFile $outputFile @requestOpts diff --git a/exercises/practice/darts/bin/fetch-cobolcheck.ps1 b/exercises/practice/darts/bin/fetch-cobolcheck.ps1 index 9228452c..ed32d5ad 100644 --- a/exercises/practice/darts/bin/fetch-cobolcheck.ps1 +++ b/exercises/practice/darts/bin/fetch-cobolcheck.ps1 @@ -23,5 +23,7 @@ Function Get-DownloadUrl { } $downloadUrl = Get-DownloadUrl -$outputFile = Join-Path -Path "${HOME}" "cobolcheck" "cobolcheck.exe" +$outputDir = Join-Path -Path "${HOME}" "cobolcheck" +New-Item -Path "${outputDir}" -ItemType "directory" +$outputFile = Join-Path -Path "${outputDir}" "cobolcheck.exe" Invoke-WebRequest -Uri $downloadUrl -OutFile $outputFile @requestOpts diff --git a/exercises/practice/diamond/bin/fetch-cobolcheck.ps1 b/exercises/practice/diamond/bin/fetch-cobolcheck.ps1 index 9228452c..ed32d5ad 100644 --- a/exercises/practice/diamond/bin/fetch-cobolcheck.ps1 +++ b/exercises/practice/diamond/bin/fetch-cobolcheck.ps1 @@ -23,5 +23,7 @@ Function Get-DownloadUrl { } $downloadUrl = Get-DownloadUrl -$outputFile = Join-Path -Path "${HOME}" "cobolcheck" "cobolcheck.exe" +$outputDir = Join-Path -Path "${HOME}" "cobolcheck" +New-Item -Path "${outputDir}" -ItemType "directory" +$outputFile = Join-Path -Path "${outputDir}" "cobolcheck.exe" Invoke-WebRequest -Uri $downloadUrl -OutFile $outputFile @requestOpts diff --git a/exercises/practice/difference-of-squares/bin/fetch-cobolcheck.ps1 b/exercises/practice/difference-of-squares/bin/fetch-cobolcheck.ps1 index 9228452c..ed32d5ad 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 "${HOME}" "cobolcheck" "cobolcheck.exe" +$outputDir = Join-Path -Path "${HOME}" "cobolcheck" +New-Item -Path "${outputDir}" -ItemType "directory" +$outputFile = Join-Path -Path "${outputDir}" "cobolcheck.exe" Invoke-WebRequest -Uri $downloadUrl -OutFile $outputFile @requestOpts diff --git a/exercises/practice/eliuds-eggs/bin/fetch-cobolcheck.ps1 b/exercises/practice/eliuds-eggs/bin/fetch-cobolcheck.ps1 index 9228452c..ed32d5ad 100644 --- a/exercises/practice/eliuds-eggs/bin/fetch-cobolcheck.ps1 +++ b/exercises/practice/eliuds-eggs/bin/fetch-cobolcheck.ps1 @@ -23,5 +23,7 @@ Function Get-DownloadUrl { } $downloadUrl = Get-DownloadUrl -$outputFile = Join-Path -Path "${HOME}" "cobolcheck" "cobolcheck.exe" +$outputDir = Join-Path -Path "${HOME}" "cobolcheck" +New-Item -Path "${outputDir}" -ItemType "directory" +$outputFile = Join-Path -Path "${outputDir}" "cobolcheck.exe" Invoke-WebRequest -Uri $downloadUrl -OutFile $outputFile @requestOpts diff --git a/exercises/practice/grade-school/bin/fetch-cobolcheck.ps1 b/exercises/practice/grade-school/bin/fetch-cobolcheck.ps1 index 9228452c..ed32d5ad 100644 --- a/exercises/practice/grade-school/bin/fetch-cobolcheck.ps1 +++ b/exercises/practice/grade-school/bin/fetch-cobolcheck.ps1 @@ -23,5 +23,7 @@ Function Get-DownloadUrl { } $downloadUrl = Get-DownloadUrl -$outputFile = Join-Path -Path "${HOME}" "cobolcheck" "cobolcheck.exe" +$outputDir = Join-Path -Path "${HOME}" "cobolcheck" +New-Item -Path "${outputDir}" -ItemType "directory" +$outputFile = Join-Path -Path "${outputDir}" "cobolcheck.exe" Invoke-WebRequest -Uri $downloadUrl -OutFile $outputFile @requestOpts diff --git a/exercises/practice/hamming/bin/fetch-cobolcheck.ps1 b/exercises/practice/hamming/bin/fetch-cobolcheck.ps1 index 9228452c..ed32d5ad 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 "${HOME}" "cobolcheck" "cobolcheck.exe" +$outputDir = Join-Path -Path "${HOME}" "cobolcheck" +New-Item -Path "${outputDir}" -ItemType "directory" +$outputFile = Join-Path -Path "${outputDir}" "cobolcheck.exe" Invoke-WebRequest -Uri $downloadUrl -OutFile $outputFile @requestOpts diff --git a/exercises/practice/hello-world/bin/fetch-cobolcheck.ps1 b/exercises/practice/hello-world/bin/fetch-cobolcheck.ps1 index 9228452c..ed32d5ad 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 "${HOME}" "cobolcheck" "cobolcheck.exe" +$outputDir = Join-Path -Path "${HOME}" "cobolcheck" +New-Item -Path "${outputDir}" -ItemType "directory" +$outputFile = Join-Path -Path "${outputDir}" "cobolcheck.exe" Invoke-WebRequest -Uri $downloadUrl -OutFile $outputFile @requestOpts diff --git a/exercises/practice/high-scores/bin/fetch-cobolcheck.ps1 b/exercises/practice/high-scores/bin/fetch-cobolcheck.ps1 index 9228452c..ed32d5ad 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 "${HOME}" "cobolcheck" "cobolcheck.exe" +$outputDir = Join-Path -Path "${HOME}" "cobolcheck" +New-Item -Path "${outputDir}" -ItemType "directory" +$outputFile = Join-Path -Path "${outputDir}" "cobolcheck.exe" Invoke-WebRequest -Uri $downloadUrl -OutFile $outputFile @requestOpts diff --git a/exercises/practice/isogram/bin/fetch-cobolcheck.ps1 b/exercises/practice/isogram/bin/fetch-cobolcheck.ps1 index 9228452c..ed32d5ad 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 "${HOME}" "cobolcheck" "cobolcheck.exe" +$outputDir = Join-Path -Path "${HOME}" "cobolcheck" +New-Item -Path "${outputDir}" -ItemType "directory" +$outputFile = Join-Path -Path "${outputDir}" "cobolcheck.exe" Invoke-WebRequest -Uri $downloadUrl -OutFile $outputFile @requestOpts diff --git a/exercises/practice/knapsack/bin/fetch-cobolcheck.ps1 b/exercises/practice/knapsack/bin/fetch-cobolcheck.ps1 index 9228452c..ed32d5ad 100644 --- a/exercises/practice/knapsack/bin/fetch-cobolcheck.ps1 +++ b/exercises/practice/knapsack/bin/fetch-cobolcheck.ps1 @@ -23,5 +23,7 @@ Function Get-DownloadUrl { } $downloadUrl = Get-DownloadUrl -$outputFile = Join-Path -Path "${HOME}" "cobolcheck" "cobolcheck.exe" +$outputDir = Join-Path -Path "${HOME}" "cobolcheck" +New-Item -Path "${outputDir}" -ItemType "directory" +$outputFile = Join-Path -Path "${outputDir}" "cobolcheck.exe" Invoke-WebRequest -Uri $downloadUrl -OutFile $outputFile @requestOpts diff --git a/exercises/practice/leap/bin/fetch-cobolcheck.ps1 b/exercises/practice/leap/bin/fetch-cobolcheck.ps1 index 9228452c..ed32d5ad 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 "${HOME}" "cobolcheck" "cobolcheck.exe" +$outputDir = Join-Path -Path "${HOME}" "cobolcheck" +New-Item -Path "${outputDir}" -ItemType "directory" +$outputFile = Join-Path -Path "${outputDir}" "cobolcheck.exe" Invoke-WebRequest -Uri $downloadUrl -OutFile $outputFile @requestOpts diff --git a/exercises/practice/luhn/bin/fetch-cobolcheck.ps1 b/exercises/practice/luhn/bin/fetch-cobolcheck.ps1 index 9228452c..ed32d5ad 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 "${HOME}" "cobolcheck" "cobolcheck.exe" +$outputDir = Join-Path -Path "${HOME}" "cobolcheck" +New-Item -Path "${outputDir}" -ItemType "directory" +$outputFile = Join-Path -Path "${outputDir}" "cobolcheck.exe" Invoke-WebRequest -Uri $downloadUrl -OutFile $outputFile @requestOpts diff --git a/exercises/practice/matching-brackets/bin/fetch-cobolcheck.ps1 b/exercises/practice/matching-brackets/bin/fetch-cobolcheck.ps1 index 9228452c..ed32d5ad 100644 --- a/exercises/practice/matching-brackets/bin/fetch-cobolcheck.ps1 +++ b/exercises/practice/matching-brackets/bin/fetch-cobolcheck.ps1 @@ -23,5 +23,7 @@ Function Get-DownloadUrl { } $downloadUrl = Get-DownloadUrl -$outputFile = Join-Path -Path "${HOME}" "cobolcheck" "cobolcheck.exe" +$outputDir = Join-Path -Path "${HOME}" "cobolcheck" +New-Item -Path "${outputDir}" -ItemType "directory" +$outputFile = Join-Path -Path "${outputDir}" "cobolcheck.exe" Invoke-WebRequest -Uri $downloadUrl -OutFile $outputFile @requestOpts diff --git a/exercises/practice/meetup/bin/fetch-cobolcheck.ps1 b/exercises/practice/meetup/bin/fetch-cobolcheck.ps1 index 9228452c..ed32d5ad 100644 --- a/exercises/practice/meetup/bin/fetch-cobolcheck.ps1 +++ b/exercises/practice/meetup/bin/fetch-cobolcheck.ps1 @@ -23,5 +23,7 @@ Function Get-DownloadUrl { } $downloadUrl = Get-DownloadUrl -$outputFile = Join-Path -Path "${HOME}" "cobolcheck" "cobolcheck.exe" +$outputDir = Join-Path -Path "${HOME}" "cobolcheck" +New-Item -Path "${outputDir}" -ItemType "directory" +$outputFile = Join-Path -Path "${outputDir}" "cobolcheck.exe" Invoke-WebRequest -Uri $downloadUrl -OutFile $outputFile @requestOpts diff --git a/exercises/practice/nucleotide-count/bin/fetch-cobolcheck.ps1 b/exercises/practice/nucleotide-count/bin/fetch-cobolcheck.ps1 index 9228452c..ed32d5ad 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 "${HOME}" "cobolcheck" "cobolcheck.exe" +$outputDir = Join-Path -Path "${HOME}" "cobolcheck" +New-Item -Path "${outputDir}" -ItemType "directory" +$outputFile = Join-Path -Path "${outputDir}" "cobolcheck.exe" Invoke-WebRequest -Uri $downloadUrl -OutFile $outputFile @requestOpts diff --git a/exercises/practice/pangram/bin/fetch-cobolcheck.ps1 b/exercises/practice/pangram/bin/fetch-cobolcheck.ps1 index 9228452c..ed32d5ad 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 "${HOME}" "cobolcheck" "cobolcheck.exe" +$outputDir = Join-Path -Path "${HOME}" "cobolcheck" +New-Item -Path "${outputDir}" -ItemType "directory" +$outputFile = Join-Path -Path "${outputDir}" "cobolcheck.exe" Invoke-WebRequest -Uri $downloadUrl -OutFile $outputFile @requestOpts diff --git a/exercises/practice/pascals-triangle/bin/fetch-cobolcheck.ps1 b/exercises/practice/pascals-triangle/bin/fetch-cobolcheck.ps1 index 9228452c..ed32d5ad 100644 --- a/exercises/practice/pascals-triangle/bin/fetch-cobolcheck.ps1 +++ b/exercises/practice/pascals-triangle/bin/fetch-cobolcheck.ps1 @@ -23,5 +23,7 @@ Function Get-DownloadUrl { } $downloadUrl = Get-DownloadUrl -$outputFile = Join-Path -Path "${HOME}" "cobolcheck" "cobolcheck.exe" +$outputDir = Join-Path -Path "${HOME}" "cobolcheck" +New-Item -Path "${outputDir}" -ItemType "directory" +$outputFile = Join-Path -Path "${outputDir}" "cobolcheck.exe" Invoke-WebRequest -Uri $downloadUrl -OutFile $outputFile @requestOpts diff --git a/exercises/practice/pig-latin/bin/fetch-cobolcheck.ps1 b/exercises/practice/pig-latin/bin/fetch-cobolcheck.ps1 index 9228452c..ed32d5ad 100644 --- a/exercises/practice/pig-latin/bin/fetch-cobolcheck.ps1 +++ b/exercises/practice/pig-latin/bin/fetch-cobolcheck.ps1 @@ -23,5 +23,7 @@ Function Get-DownloadUrl { } $downloadUrl = Get-DownloadUrl -$outputFile = Join-Path -Path "${HOME}" "cobolcheck" "cobolcheck.exe" +$outputDir = Join-Path -Path "${HOME}" "cobolcheck" +New-Item -Path "${outputDir}" -ItemType "directory" +$outputFile = Join-Path -Path "${outputDir}" "cobolcheck.exe" Invoke-WebRequest -Uri $downloadUrl -OutFile $outputFile @requestOpts diff --git a/exercises/practice/protein-translation/bin/fetch-cobolcheck.ps1 b/exercises/practice/protein-translation/bin/fetch-cobolcheck.ps1 index 9228452c..ed32d5ad 100644 --- a/exercises/practice/protein-translation/bin/fetch-cobolcheck.ps1 +++ b/exercises/practice/protein-translation/bin/fetch-cobolcheck.ps1 @@ -23,5 +23,7 @@ Function Get-DownloadUrl { } $downloadUrl = Get-DownloadUrl -$outputFile = Join-Path -Path "${HOME}" "cobolcheck" "cobolcheck.exe" +$outputDir = Join-Path -Path "${HOME}" "cobolcheck" +New-Item -Path "${outputDir}" -ItemType "directory" +$outputFile = Join-Path -Path "${outputDir}" "cobolcheck.exe" Invoke-WebRequest -Uri $downloadUrl -OutFile $outputFile @requestOpts diff --git a/exercises/practice/queen-attack/bin/fetch-cobolcheck.ps1 b/exercises/practice/queen-attack/bin/fetch-cobolcheck.ps1 index 9228452c..ed32d5ad 100644 --- a/exercises/practice/queen-attack/bin/fetch-cobolcheck.ps1 +++ b/exercises/practice/queen-attack/bin/fetch-cobolcheck.ps1 @@ -23,5 +23,7 @@ Function Get-DownloadUrl { } $downloadUrl = Get-DownloadUrl -$outputFile = Join-Path -Path "${HOME}" "cobolcheck" "cobolcheck.exe" +$outputDir = Join-Path -Path "${HOME}" "cobolcheck" +New-Item -Path "${outputDir}" -ItemType "directory" +$outputFile = Join-Path -Path "${outputDir}" "cobolcheck.exe" Invoke-WebRequest -Uri $downloadUrl -OutFile $outputFile @requestOpts diff --git a/exercises/practice/raindrops/bin/fetch-cobolcheck.ps1 b/exercises/practice/raindrops/bin/fetch-cobolcheck.ps1 index 9228452c..ed32d5ad 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 "${HOME}" "cobolcheck" "cobolcheck.exe" +$outputDir = Join-Path -Path "${HOME}" "cobolcheck" +New-Item -Path "${outputDir}" -ItemType "directory" +$outputFile = Join-Path -Path "${outputDir}" "cobolcheck.exe" Invoke-WebRequest -Uri $downloadUrl -OutFile $outputFile @requestOpts diff --git a/exercises/practice/reverse-string/bin/fetch-cobolcheck.ps1 b/exercises/practice/reverse-string/bin/fetch-cobolcheck.ps1 index 9228452c..ed32d5ad 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 "${HOME}" "cobolcheck" "cobolcheck.exe" +$outputDir = Join-Path -Path "${HOME}" "cobolcheck" +New-Item -Path "${outputDir}" -ItemType "directory" +$outputFile = Join-Path -Path "${outputDir}" "cobolcheck.exe" Invoke-WebRequest -Uri $downloadUrl -OutFile $outputFile @requestOpts diff --git a/exercises/practice/rna-transcription/bin/fetch-cobolcheck.ps1 b/exercises/practice/rna-transcription/bin/fetch-cobolcheck.ps1 index 9228452c..ed32d5ad 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 "${HOME}" "cobolcheck" "cobolcheck.exe" +$outputDir = Join-Path -Path "${HOME}" "cobolcheck" +New-Item -Path "${outputDir}" -ItemType "directory" +$outputFile = Join-Path -Path "${outputDir}" "cobolcheck.exe" Invoke-WebRequest -Uri $downloadUrl -OutFile $outputFile @requestOpts diff --git a/exercises/practice/robot-simulator/bin/fetch-cobolcheck.ps1 b/exercises/practice/robot-simulator/bin/fetch-cobolcheck.ps1 index 9228452c..ed32d5ad 100644 --- a/exercises/practice/robot-simulator/bin/fetch-cobolcheck.ps1 +++ b/exercises/practice/robot-simulator/bin/fetch-cobolcheck.ps1 @@ -23,5 +23,7 @@ Function Get-DownloadUrl { } $downloadUrl = Get-DownloadUrl -$outputFile = Join-Path -Path "${HOME}" "cobolcheck" "cobolcheck.exe" +$outputDir = Join-Path -Path "${HOME}" "cobolcheck" +New-Item -Path "${outputDir}" -ItemType "directory" +$outputFile = Join-Path -Path "${outputDir}" "cobolcheck.exe" Invoke-WebRequest -Uri $downloadUrl -OutFile $outputFile @requestOpts diff --git a/exercises/practice/roman-numerals/bin/fetch-cobolcheck.ps1 b/exercises/practice/roman-numerals/bin/fetch-cobolcheck.ps1 index 9228452c..ed32d5ad 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 "${HOME}" "cobolcheck" "cobolcheck.exe" +$outputDir = Join-Path -Path "${HOME}" "cobolcheck" +New-Item -Path "${outputDir}" -ItemType "directory" +$outputFile = Join-Path -Path "${outputDir}" "cobolcheck.exe" Invoke-WebRequest -Uri $downloadUrl -OutFile $outputFile @requestOpts diff --git a/exercises/practice/rotational-cipher/bin/fetch-cobolcheck.ps1 b/exercises/practice/rotational-cipher/bin/fetch-cobolcheck.ps1 index 9228452c..ed32d5ad 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 "${HOME}" "cobolcheck" "cobolcheck.exe" +$outputDir = Join-Path -Path "${HOME}" "cobolcheck" +New-Item -Path "${outputDir}" -ItemType "directory" +$outputFile = Join-Path -Path "${outputDir}" "cobolcheck.exe" Invoke-WebRequest -Uri $downloadUrl -OutFile $outputFile @requestOpts diff --git a/exercises/practice/scrabble-score/bin/fetch-cobolcheck.ps1 b/exercises/practice/scrabble-score/bin/fetch-cobolcheck.ps1 index 9228452c..ed32d5ad 100644 --- a/exercises/practice/scrabble-score/bin/fetch-cobolcheck.ps1 +++ b/exercises/practice/scrabble-score/bin/fetch-cobolcheck.ps1 @@ -23,5 +23,7 @@ Function Get-DownloadUrl { } $downloadUrl = Get-DownloadUrl -$outputFile = Join-Path -Path "${HOME}" "cobolcheck" "cobolcheck.exe" +$outputDir = Join-Path -Path "${HOME}" "cobolcheck" +New-Item -Path "${outputDir}" -ItemType "directory" +$outputFile = Join-Path -Path "${outputDir}" "cobolcheck.exe" Invoke-WebRequest -Uri $downloadUrl -OutFile $outputFile @requestOpts diff --git a/exercises/practice/secret-handshake/bin/fetch-cobolcheck.ps1 b/exercises/practice/secret-handshake/bin/fetch-cobolcheck.ps1 index 9228452c..ed32d5ad 100644 --- a/exercises/practice/secret-handshake/bin/fetch-cobolcheck.ps1 +++ b/exercises/practice/secret-handshake/bin/fetch-cobolcheck.ps1 @@ -23,5 +23,7 @@ Function Get-DownloadUrl { } $downloadUrl = Get-DownloadUrl -$outputFile = Join-Path -Path "${HOME}" "cobolcheck" "cobolcheck.exe" +$outputDir = Join-Path -Path "${HOME}" "cobolcheck" +New-Item -Path "${outputDir}" -ItemType "directory" +$outputFile = Join-Path -Path "${outputDir}" "cobolcheck.exe" Invoke-WebRequest -Uri $downloadUrl -OutFile $outputFile @requestOpts diff --git a/exercises/practice/sieve/bin/fetch-cobolcheck.ps1 b/exercises/practice/sieve/bin/fetch-cobolcheck.ps1 index 9228452c..ed32d5ad 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 "${HOME}" "cobolcheck" "cobolcheck.exe" +$outputDir = Join-Path -Path "${HOME}" "cobolcheck" +New-Item -Path "${outputDir}" -ItemType "directory" +$outputFile = Join-Path -Path "${outputDir}" "cobolcheck.exe" Invoke-WebRequest -Uri $downloadUrl -OutFile $outputFile @requestOpts diff --git a/exercises/practice/space-age/bin/fetch-cobolcheck.ps1 b/exercises/practice/space-age/bin/fetch-cobolcheck.ps1 index 9228452c..ed32d5ad 100644 --- a/exercises/practice/space-age/bin/fetch-cobolcheck.ps1 +++ b/exercises/practice/space-age/bin/fetch-cobolcheck.ps1 @@ -23,5 +23,7 @@ Function Get-DownloadUrl { } $downloadUrl = Get-DownloadUrl -$outputFile = Join-Path -Path "${HOME}" "cobolcheck" "cobolcheck.exe" +$outputDir = Join-Path -Path "${HOME}" "cobolcheck" +New-Item -Path "${outputDir}" -ItemType "directory" +$outputFile = Join-Path -Path "${outputDir}" "cobolcheck.exe" Invoke-WebRequest -Uri $downloadUrl -OutFile $outputFile @requestOpts diff --git a/exercises/practice/square-root/bin/fetch-cobolcheck.ps1 b/exercises/practice/square-root/bin/fetch-cobolcheck.ps1 index 9228452c..ed32d5ad 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 "${HOME}" "cobolcheck" "cobolcheck.exe" +$outputDir = Join-Path -Path "${HOME}" "cobolcheck" +New-Item -Path "${outputDir}" -ItemType "directory" +$outputFile = Join-Path -Path "${outputDir}" "cobolcheck.exe" Invoke-WebRequest -Uri $downloadUrl -OutFile $outputFile @requestOpts diff --git a/exercises/practice/triangle/bin/fetch-cobolcheck.ps1 b/exercises/practice/triangle/bin/fetch-cobolcheck.ps1 index 9228452c..ed32d5ad 100644 --- a/exercises/practice/triangle/bin/fetch-cobolcheck.ps1 +++ b/exercises/practice/triangle/bin/fetch-cobolcheck.ps1 @@ -23,5 +23,7 @@ Function Get-DownloadUrl { } $downloadUrl = Get-DownloadUrl -$outputFile = Join-Path -Path "${HOME}" "cobolcheck" "cobolcheck.exe" +$outputDir = Join-Path -Path "${HOME}" "cobolcheck" +New-Item -Path "${outputDir}" -ItemType "directory" +$outputFile = Join-Path -Path "${outputDir}" "cobolcheck.exe" Invoke-WebRequest -Uri $downloadUrl -OutFile $outputFile @requestOpts diff --git a/exercises/practice/two-fer/bin/fetch-cobolcheck.ps1 b/exercises/practice/two-fer/bin/fetch-cobolcheck.ps1 index 9228452c..ed32d5ad 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 "${HOME}" "cobolcheck" "cobolcheck.exe" +$outputDir = Join-Path -Path "${HOME}" "cobolcheck" +New-Item -Path "${outputDir}" -ItemType "directory" +$outputFile = Join-Path -Path "${outputDir}" "cobolcheck.exe" Invoke-WebRequest -Uri $downloadUrl -OutFile $outputFile @requestOpts diff --git a/exercises/practice/yacht/bin/fetch-cobolcheck.ps1 b/exercises/practice/yacht/bin/fetch-cobolcheck.ps1 index 9228452c..ed32d5ad 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 "${HOME}" "cobolcheck" "cobolcheck.exe" +$outputDir = Join-Path -Path "${HOME}" "cobolcheck" +New-Item -Path "${outputDir}" -ItemType "directory" +$outputFile = Join-Path -Path "${outputDir}" "cobolcheck.exe" Invoke-WebRequest -Uri $downloadUrl -OutFile $outputFile @requestOpts