Although there's no Bash script dependency manager like npm for JavaScript, Maven for Java, pip for Python, or composer for PHP; you can add bashunit as a dependency in your repository according to your preferences.
Here, we provide different options that you can use to install bashunit in your application.
bashunit requires Bash 3.0 or newer.
There is a tool that will generate an executable with the whole library in a single file:
::: code-group
curl -s https://bashunit.typeddevs.com/install.sh | bash# IMPORTANT: You need WSL (Windows Subsystem for Linux) to run bashunit
#
# Step 1: Install WSL if you haven't already
# - Open PowerShell as Administrator
# - Run: wsl --install
# - Restart your computer
#
# Step 2: Open your WSL terminal and run:
curl -s https://bashunit.typeddevs.com/install.sh | bash:::
This will create a file inside a lib folder, such as lib/bashunit.
# Verify the sha256sum for latest stable: {{ pkg.version }}
DIR="lib"; KNOWN_HASH="{{pkg.checksum}}"; FILE="$DIR/bashunit"; [ "$(shasum -a 256 "$FILE" | awk '{ print $1 }')" = "$KNOWN_HASH" ] && echo -e "✓ \033[1mbashunit\033[0m verified." || { echo -e "✗ \033[1mbashunit\033[0m corrupt"; rm "$FILE"; }
:::tip You can find the checksum for each version inside GitHub's releases. E.g.:
https://github.com/TypedDevs/bashunit/releases/download/{{ pkg.version }}/checksum
:::
The installation script can receive arguments (in any order):
::: code-group
curl -s https://bashunit.typeddevs.com/install.sh | bash -s [dir] [version]# IMPORTANT: You need WSL (Windows Subsystem for Linux) to run bashunit
#
# Step 1: Install WSL if you haven't already
# - Open PowerShell as Administrator
# - Run: wsl --install
# - Restart your computer
#
# Step 2: Open your WSL terminal and run:
curl -s https://bashunit.typeddevs.com/install.sh | bash -s [dir] [version]:::
[dir]: the destiny directory to save the executable bashunit;libby default[version]: the release to download, for instance{{ pkg.version }};latestby default.
::: tip
You can use beta as [version] to get the next non-stable preview release.
We try to keep it stable, but there is no promise that we won't change functions or their signatures without prior notice.
:::
::: tip Committing (or not) this file to your project it's up to you. In the end, it is a dev dependency. :::
You can manage your dependencies using bashdep, a simple dependency manager for bash.
::: code-group
# Ensure bashdep is installed
[ ! -f lib/bashdep ] && {
mkdir -p lib
curl -sLo lib/bashdep \
https://github.com/Chemaclass/bashdep/releases/download/0.1/bashdep
chmod +x lib/bashdep
}
# Add latest bashunit release to your dependencies
DEPENDENCIES=(
"https://github.com/TypedDevs/bashunit/releases/download/{{ pkg.version }}/bashunit"
)
# Load, configure and run bashdep
source lib/bashdep
bashdep::setup dir="lib" silent=false
bashdep::install "${DEPENDENCIES[@]}"
# IMPORTANT: You need WSL (Windows Subsystem for Linux) to run bashunit
#
# Step 1: Install WSL if you haven't already
# - Open PowerShell as Administrator
# - Run: wsl --install
# - Restart your computer
#
# Step 2: Open your WSL terminal and run:
# Ensure bashdep is installed
[ ! -f lib/bashdep ] && {
mkdir -p lib
curl -sLo lib/bashdep \
https://github.com/Chemaclass/bashdep/releases/download/0.1/bashdep
chmod +x lib/bashdep
}
# Add latest bashunit release to your dependencies
DEPENDENCIES=(
"https://github.com/TypedDevs/bashunit/releases/download/{{ pkg.version }}/bashunit"
)
# Load, configure and run bashdep
source lib/bashdep
bashdep::setup dir="lib" silent=false
bashdep::install "${DEPENDENCIES[@]}"
Downloading 'bashunit' to 'lib'...
> bashunit installed successfully in 'lib'
:::
You can install bashunit globally on macOS or Linux using brew.
brew install bashunitOn macOS, you can also install bashunit via MacPorts:
sudo port install bashunit# example: .github/workflows/bashunit-tests.yml
name: Tests
on:
pull_request:
push:
branches:
- main
jobs:
tests:
name: "Run tests"
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: "Install bashunit"
run: |
curl -s https://bashunit.typeddevs.com/install.sh > install.sh
chmod +x install.sh
./install.sh
- name: "Test"
run: "./lib/bashunit tests"::: tip Get inspiration from the pipelines running on the bashunit-project itself: https://github.com/TypedDevs/bashunit/blob/main/.github/workflows/tests.yml :::
<script setup> import pkg from '../package.json' </script>