File tree Expand file tree Collapse file tree 4 files changed +53
-4
lines changed Expand file tree Collapse file tree 4 files changed +53
-4
lines changed Original file line number Diff line number Diff line change 1010- Support placeholder ` ::ignore:: ` in snapshots
1111- Add project overview docs
1212- Improve clock performance
13+ - Make install.sh args more flexible
1314
1415## [ 0.20.0] ( https://github.com/TypedDevs/bashunit/compare/0.19.1...0.20.0 ) - 2025-06-01
1516
Original file line number Diff line number Diff line change @@ -31,13 +31,13 @@ https://github.com/TypedDevs/bashunit/releases/download/{{ pkg.version }}/checks
3131
3232#### Define custom tag and folder
3333
34- The installation script can receive two optional arguments :
34+ The installation script can receive arguments (in any order) :
3535
3636``` bash
3737curl -s https://bashunit.typeddevs.com/install.sh | bash -s [dir] [version]
3838```
3939- ` [dir] ` : the destiny directory to save the executable bashunit; ` lib ` by default
40- - ` [version] ` : the [ release] ( https://github.com/TypedDevs/bashunit/releases ) to download, for instance ` {{ pkg.version }} ` ; ` latest ` by default
40+ - ` [version] ` : the [ release] ( https://github.com/TypedDevs/bashunit/releases ) to download, for instance ` {{ pkg.version }} ` ; ` latest ` by default.
4141
4242::: tip
4343You can use ` beta ` as ` [version] ` to get the next non-stable preview release.
Original file line number Diff line number Diff line change @@ -63,8 +63,33 @@ function install() {
6363# ######## MAIN ##########
6464# ########################
6565
66- DIR=${1-lib}
67- VERSION=${2-latest}
66+ # Defaults
67+ DIR=" lib"
68+ VERSION=" latest"
69+
70+ function is_version() {
71+ [[ " $1 " =~ ^[0-9]+\. [0-9]+\. [0-9]+$ || " $1 " == " latest" || " $1 " == " beta" ]]
72+ }
73+
74+ # Parse arguments flexibly
75+ if [[ $# -eq 1 ]]; then
76+ if is_version " $1 " ; then
77+ VERSION=" $1 "
78+ else
79+ DIR=" $1 "
80+ fi
81+ elif [[ $# -eq 2 ]]; then
82+ if is_version " $1 " ; then
83+ VERSION=" $1 "
84+ DIR=" $2 "
85+ elif is_version " $2 " ; then
86+ DIR=" $1 "
87+ VERSION=" $2 "
88+ else
89+ echo " Invalid arguments. Expected version or directory." >&2
90+ exit 1
91+ fi
92+ fi
6893
6994BASHUNIT_GIT_REPO=" https://github.com/TypedDevs/bashunit"
7095if is_git_installed; then
Original file line number Diff line number Diff line change @@ -84,6 +84,29 @@ function test_install_downloads_the_given_version() {
8484 " $( " $installed_bashunit " --env " $TEST_ENV_FILE " --version) "
8585}
8686
87+ function test_install_downloads_the_given_version_without_dir() {
88+ if [[ " $ACTIVE_INTERNET " -eq 1 ]]; then
89+ skip " no internet connection" && return
90+ fi
91+
92+ local installed_bashunit=" ./lib/bashunit"
93+ local output
94+ output=" $( ./install.sh 0.19.0) "
95+
96+ assert_same \
97+ " $( printf " %s\n" \
98+ " > Downloading a concrete version: '0.19.0'" \
99+ " > bashunit has been installed in the 'lib' folder" \
100+ ) " \
101+ " $output "
102+
103+ assert_file_exists " $installed_bashunit "
104+
105+ assert_same \
106+ " $( printf " \e[1m\e[32mbashunit\e[0m - 0.19.0" ) " \
107+ " $( " $installed_bashunit " --env " $TEST_ENV_FILE " --version) "
108+ }
109+
87110function test_install_downloads_the_non_stable_beta_version() {
88111 if [[ " $ACTIVE_INTERNET " -eq 1 ]]; then
89112 skip " no internet connection" && return
You can’t perform that action at this time.
0 commit comments