Skip to content

Commit 2379668

Browse files
committed
feat: enhanced the dev script
1 parent 069c40e commit 2379668

File tree

1 file changed

+34
-6
lines changed

1 file changed

+34
-6
lines changed

scripts/dev.sh

+34-6
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,18 @@ if [ ! -d "$PACKAGES_DIR" ]; then
1111
exit 1
1212
fi
1313

14+
# Function to check if an item is in an array
15+
is_in_array() {
16+
local item="$1"
17+
shift
18+
for element; do
19+
if [[ "$element" == "$item" ]]; then
20+
return 0
21+
fi
22+
done
23+
return 1
24+
}
25+
1426
# Initialize an array to hold package-specific commands
1527
COMMANDS=()
1628

@@ -28,18 +40,34 @@ EXCLUDED_FOLDERS=("create-eliza-app" "debug_audio" "content_cache")
2840
for PACKAGE in "$PACKAGES_DIR"/*; do
2941
PACKAGE_NAME=$(basename "$PACKAGE")
3042

31-
# Skip excluded folders
32-
if [ -d "$PACKAGE" ] && [[ ! " ${EXCLUDED_FOLDERS[@]} " =~ " ${PACKAGE_NAME} " ]] && [ "$PACKAGE_NAME" != "core" ]; then
43+
# Skip excluded folders and "core"
44+
if [ -d "$PACKAGE" ] && ! is_in_array "$PACKAGE_NAME" "${EXCLUDED_FOLDERS[@]}" && [ "$PACKAGE_NAME" != "core" ]; then
3345
COMMANDS+=("pnpm --dir $PACKAGE dev -- $*")
3446
fi
3547
done
3648

3749
# Add specific commands for other directories or cases
38-
COMMANDS+=("pnpm --dir client dev -- $*")
39-
COMMANDS+=("node -e \"setTimeout(() => process.exit(0), 5000)\" && pnpm --dir agent dev -- $*")
50+
if [ -d "./client" ]; then
51+
COMMANDS+=("pnpm --dir client dev -- $*")
52+
else
53+
echo "Warning: 'client' directory not found."
54+
fi
55+
56+
if [ -d "./agent" ]; then
57+
COMMANDS+=("node -e \"setTimeout(() => process.exit(0), 5000)\" && pnpm --dir agent dev -- $*")
58+
else
59+
echo "Warning: 'agent' directory not found."
60+
fi
4061

4162
# Run build command first
42-
pnpm dev:build
63+
if ! pnpm dev:build; then
64+
echo "Build failed. Exiting."
65+
exit 1
66+
fi
4367

4468
# Run all commands concurrently
45-
npx concurrently --raw "${COMMANDS[@]}"
69+
if [ ${#COMMANDS[@]} -gt 0 ]; then
70+
npx concurrently --raw "${COMMANDS[@]}"
71+
else
72+
echo "No valid packages to run."
73+
fi

0 commit comments

Comments
 (0)