Skip to content

Commit cd44cf0

Browse files
committed
more resilient count script
1 parent 58c3b2f commit cd44cf0

File tree

1 file changed

+17
-7
lines changed

1 file changed

+17
-7
lines changed

scripts/package-count.sh

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -31,13 +31,23 @@ infer_package_manager() {
3131
fi
3232
}
3333

34-
BENCH_PACKAGE_COUNT=$(
35-
find node_modules -name package.json -type f \
36-
| grep -E 'node_modules/([a-zA-Z0-9_-]+)/package\.json$|node_modules/@[a-zA-Z0-9_-]+/[a-zA-Z0-9_-]+/package\.json$' \
37-
| sort -u \
38-
| wc -l \
39-
| xargs
40-
) || echo "0"
34+
# If the node_modules directory exists, count the number of packages
35+
if [ -d "node_modules" ]; then
36+
BENCH_PACKAGE_COUNT=$(
37+
find node_modules -name package.json -type f \
38+
| grep -E 'node_modules/([a-zA-Z0-9_-]+)/package\.json$|node_modules/@[a-zA-Z0-9_-]+/[a-zA-Z0-9_-]+/package\.json$' \
39+
| sort -u \
40+
| wc -l \
41+
| xargs
42+
)
43+
else
44+
BENCH_PACKAGE_COUNT="0"
45+
fi
46+
47+
# If the package count is not set, set it to 0
48+
if [ -z "${BENCH_PACKAGE_COUNT:-}" ]; then
49+
BENCH_PACKAGE_COUNT="0"
50+
fi
4151

4252
BENCH_PACKAGE_MANAGER=$(
4353
infer_package_manager

0 commit comments

Comments
 (0)