Skip to content

Commit a066d25

Browse files
committed
feat(steps-lib): add directory_exists helper fn
1 parent 8ad4020 commit a066d25

File tree

2 files changed

+20
-0
lines changed

2 files changed

+20
-0
lines changed

ci/steps/steps-lib.sh

+10
Original file line numberDiff line numberDiff line change
@@ -15,3 +15,13 @@ is_env_var_set() {
1515
echo 1
1616
fi
1717
}
18+
19+
# Checks whether a directory exists.
20+
directory_exists() {
21+
local dir="${1:-}"
22+
if [[ -d "${dir:-}" ]]; then
23+
echo 0
24+
else
25+
echo 1
26+
fi
27+
}

test/scripts/steps-lib.bats

+10
Original file line numberDiff line numberDiff line change
@@ -14,3 +14,13 @@ source "$SCRIPT"
1414
ASDF_TEST_SET="test" run is_env_var_set "ASDF_TEST_SET"
1515
[ "$output" = 0 ]
1616
}
17+
18+
@test "directory_exists should 1 if directory doesn't exist" {
19+
run directory_exists "/tmp/asdfasdfasdf"
20+
[ "$output" = 1 ]
21+
}
22+
23+
@test "directory_exists should 0 if directory exists" {
24+
run directory_exists "$(pwd)"
25+
[ "$output" = 0 ]
26+
}

0 commit comments

Comments
 (0)