Skip to content

Commit 69a4486

Browse files
committed
Make package verifier portable without rg
1 parent 07bfefc commit 69a4486

1 file changed

Lines changed: 21 additions & 3 deletions

File tree

‎scripts/verify-package.sh‎

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,25 +6,43 @@ trap 'rm -f "$manifest"' EXIT
66

77
cargo package --allow-dirty --list > "$manifest"
88

9+
if command -v rg >/dev/null 2>&1; then
10+
search_exact() {
11+
rg -Fxq "$1" "$manifest"
12+
}
13+
14+
search_prefix() {
15+
rg -q "^$1" "$manifest"
16+
}
17+
else
18+
search_exact() {
19+
grep -Fxq "$1" "$manifest"
20+
}
21+
22+
search_prefix() {
23+
grep -Eq "^$1" "$manifest"
24+
}
25+
fi
26+
927
require() {
1028
local path="$1"
11-
if ! rg -Fxq "$path" "$manifest"; then
29+
if ! search_exact "$path"; then
1230
echo "missing packaged file: $path" >&2
1331
exit 1
1432
fi
1533
}
1634

1735
reject_prefix() {
1836
local prefix="$1"
19-
if rg -q "^${prefix}" "$manifest"; then
37+
if search_prefix "$prefix"; then
2038
echo "unexpected packaged path matching prefix: $prefix" >&2
2139
exit 1
2240
fi
2341
}
2442

2543
reject_exact() {
2644
local path="$1"
27-
if rg -Fxq "$path" "$manifest"; then
45+
if search_exact "$path"; then
2846
echo "unexpected packaged file: $path" >&2
2947
exit 1
3048
fi

0 commit comments

Comments
 (0)