Skip to content

Commit 5933b0c

Browse files
brimonkcgsdev0
authored andcommitted
added caching to findRoutes
1 parent c0798d5 commit 5933b0c

File tree

2 files changed

+10
-5
lines changed

2 files changed

+10
-5
lines changed

core.sh

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -485,11 +485,14 @@ writeHttpResponse() {
485485
}
486486

487487
findRoutes() {
488-
cd pages
489-
for i in $(find . -type f,l -iname '*.sh' \
490-
| sed 's@^\./@@'); do
491-
echo $i;
492-
done
488+
local SIZE
489+
SIZE=$(stat -c "%s" $ROUTES_CACHE)
490+
if [[ $SIZE -eq 0 ]]; then
491+
cd pages
492+
find . -type f,l -iname '*.sh' | sed 's@^\./@@' | tee $ROUTES_CACHE
493+
else
494+
cat $ROUTES_CACHE
495+
fi
493496
}
494497

495498
findPredefinedRoutes() {

start.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ if [[ "${DEV:-true}" == "true" ]] && [[ ! -z "$TAILWIND" ]]; then
1010
PID=$!
1111
fi
1212

13+
export ROUTES_CACHE=$(mktemp)
14+
1315
# remove any old subscriptions; they are no longer valid
1416
rm -rf pubsub
1517

0 commit comments

Comments
 (0)