Skip to content

Commit 9303090

Browse files
committed
refactor: Make bash-object an actual library compatible with basalt
1 parent a3a4bea commit 9303090

File tree

6 files changed

+31
-88
lines changed

6 files changed

+31
-88
lines changed

pkg/bin/bobject

-61
This file was deleted.

pkg/lib/cmd/bobject-print.sh

-9
This file was deleted.

pkg/lib/source/bobject-print.sh

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# shellcheck shell=bash
2+
3+
bobject-print() {
4+
# TODO
5+
:
6+
}

pkg/lib/cmd/bobject.sh renamed to pkg/lib/source/bobject.sh

-4
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,5 @@
11
# shellcheck shell=bash
22

3-
for f in "$BASH_OBJECT_LIB_DIR"/{,util/}?*.sh; do
4-
source "$f"
5-
done
6-
73
bobject() {
84
local subcmd="$1"
95
shift

pkg/load.bash

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
# shellcheck shell=bash
2+
3+
# TODO: autogen by basalt?
4+
5+
if [ -z "$BASALT_PACKAGE_PATH" ]; then
6+
if [ "${BASH_SOURCE[0]::1}" = / ]; then
7+
BASALT_PACKAGE_PATH="${BASH_SOURCE[0]}"
8+
elif command -v greadlink &>/dev/null; then
9+
BASALT_PACKAGE_PATH="$(greadlink -f "${BASH_SOURCE[0]}")"
10+
elif command -v realfile &>/dev/null; then
11+
BASALT_PACKAGE_PATH="$(realfile "${BASH_SOURCE[0]}")"
12+
elif command -v readlink &>/dev/null; then
13+
BASALT_PACKAGE_PATH="$(readlink -f "${BASH_SOURCE[0]}")"
14+
fi
15+
16+
BASALT_PACKAGE_PATH="${BASALT_PACKAGE_PATH%/*}"
17+
BASALT_PACKAGE_PATH="${BASALT_PACKAGE_PATH%/*}"
18+
fi
19+
20+
for f in "$BASALT_PACKAGE_PATH"/pkg/lib/{,source/,util/}?*.sh; do
21+
source "$f"
22+
done

tests/util/init.sh

+3-14
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,15 @@
11
# shellcheck shell=bash
22

3+
# TODO: test for -u and -o pipefail
34
set -e
45

5-
# TODO: only do once
6-
eval "$(basalt global init bash)"
7-
6+
load '../pkg/load.bash'
87
load './util/test_util.sh'
98

9+
eval "$(basalt global init bash)"
1010
basalt-load 'github.com/ztombol/bats-support'
1111
basalt-load 'github.com/ztombol/bats-assert'
1212

13-
# TODO
14-
ROOT_DIR="$(realpath "${BASH_SOURCE[0]}")"
15-
ROOT_DIR="${ROOT_DIR%/*}"; ROOT_DIR="${ROOT_DIR%/*}"; ROOT_DIR="${ROOT_DIR%/*}"
16-
17-
export PATH="$ROOT_DIR/pkg/bin:$PATH"
18-
for f in "$ROOT_DIR"/pkg/lib/{,util}/?*.sh; do
19-
# shellcheck disable=SC1090
20-
source "$f"
21-
done
22-
source 'bobject'
23-
2413
setup() {
2514
cd "$BATS_TEST_TMPDIR"
2615
}

0 commit comments

Comments
 (0)