File tree Expand file tree Collapse file tree 1 file changed +25
-9
lines changed Expand file tree Collapse file tree 1 file changed +25
-9
lines changed Original file line number Diff line number Diff line change 1
1
#! /usr/bin/env bash
2
2
3
+ # This file is a copy of the
4
+ # https://github.com/exercism/configlet/blob/main/scripts/fetch-configlet file.
5
+ # Please submit bugfixes/improvements to the above file to ensure that all tracks benefit from the changes.
6
+
3
7
set -eo pipefail
4
8
5
9
readonly LATEST=' https://api.github.com/repos/exercism/configlet/releases/latest'
@@ -45,14 +49,26 @@ get_download_url() {
45
49
cut -d' "' -f4
46
50
}
47
51
48
- download_url=" $( get_download_url) "
49
- output_dir=" bin"
50
- output_path=" ${output_dir} /latest-configlet.${ext} "
51
- curl " ${curlopts[@]} " --output " ${output_path} " " ${download_url} "
52
+ main () {
53
+ if [[ -d ./bin ]]; then
54
+ output_dir=" ./bin"
55
+ elif [[ $PWD == * /bin ]]; then
56
+ output_dir=" $PWD "
57
+ else
58
+ echo " Error: no ./bin directory found. This script should be ran from a repo root." >&2
59
+ return 1
60
+ fi
52
61
53
- case " ${ext} " in
54
- * zip) unzip " ${output_path} " -d " ${output_dir} " ;;
55
- * ) tar xzf " ${output_path} " -C " ${output_dir} " ;;
56
- esac
62
+ download_url=" $( get_download_url) "
63
+ output_path=" ${output_dir} /latest-configlet.${ext} "
64
+ curl " ${curlopts[@]} " --output " ${output_path} " " ${download_url} "
65
+
66
+ case " ${ext} " in
67
+ * zip) unzip " ${output_path} " -d " ${output_dir} " ;;
68
+ * ) tar xzf " ${output_path} " -C " ${output_dir} " ;;
69
+ esac
70
+
71
+ rm -f " ${output_path} "
72
+ }
57
73
58
- rm -f " ${output_path} "
74
+ main
You can’t perform that action at this time.
0 commit comments