Skip to content

Commit bd9b073

Browse files
committed
swap symlinking for copying in the run-build script
1 parent 100097c commit bd9b073

File tree

1 file changed

+33
-26
lines changed

1 file changed

+33
-26
lines changed

β€Žrun-local.shβ€Ž

Lines changed: 33 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -22,36 +22,45 @@ if [ ! -d "vendor" ]; then
2222
composer install
2323
fi
2424

25-
# Prompt user for WooCommerce directory
26-
echo "πŸ“ Please provide the path to your WooCommerce directory."
27-
echo "Example: /Users/YourUserName/woocommerce/plugins/woocommerce"
28-
echo ""
29-
30-
# Read user input with a default suggestion
31-
read -p "Enter WooCommerce directory path: " WOOCOMMERCE_DIR
32-
33-
34-
# Check if directory exists
35-
if [ ! -d "$WOOCOMMERCE_DIR" ]; then
36-
echo "❌ WooCommerce plugin directory not found at: $WOOCOMMERCE_DIR"
37-
echo " Please check the path and try again."
38-
exit 1
25+
# Check if woocommerce directory exists in current directory
26+
if [ -d "woocommerce" ]; then
27+
echo "πŸ“ Found existing woocommerce directory in current project."
28+
WOOCOMMERCE_DIR="woocommerce"
29+
else
30+
# Prompt user for WooCommerce directory
31+
echo "πŸ“ Please provide the path to your WooCommerce directory."
32+
echo "Example: /Users/YourUserName/woocommerce/plugins/woocommerce"
33+
echo ""
34+
read -p "Enter WooCommerce directory path: " WOOCOMMERCE_DIR
35+
36+
# Check if directory exists
37+
if [ ! -d "$WOOCOMMERCE_DIR" ]; then
38+
echo "❌ WooCommerce plugin directory not found at: $WOOCOMMERCE_DIR"
39+
echo " Please check the path and try again."
40+
exit 1
41+
fi
3942
fi
4043

4144
echo "πŸ“ Using WooCommerce plugin directory: $WOOCOMMERCE_DIR"
4245

43-
# Create symbolic link to the WooCommerce directory
44-
if [ -L "woocommerce" ]; then
45-
echo "πŸ”— Removing existing symbolic link..."
46-
rm woocommerce
47-
elif [ -d "woocommerce" ]; then
48-
echo "πŸ—‘οΈ Removing existing woocommerce directory..."
49-
rm -rf woocommerce
46+
# Only copy files if we're using an external path (not the existing woocommerce directory)
47+
if [ "$WOOCOMMERCE_DIR" != "woocommerce" ]; then
48+
if [ -d "woocommerce" ]; then
49+
echo "πŸ—‘οΈ Removing existing woocommerce directory..."
50+
rm -rf woocommerce
51+
fi
52+
53+
echo "πŸ“ Copying WooCommerce files..."
54+
mkdir -p woocommerce
55+
56+
# Copy only the directories we want for documentation
57+
cp -r "$WOOCOMMERCE_DIR"/includes woocommerce/ 2>/dev/null || true
58+
cp -r "$WOOCOMMERCE_DIR"/src woocommerce/ 2>/dev/null || true
59+
cp -r "$WOOCOMMERCE_DIR"/templates woocommerce/ 2>/dev/null || true
60+
else
61+
echo "πŸ“ Using existing woocommerce directory in project."
5062
fi
5163

52-
echo "πŸ”— Creating symbolic link to local WooCommerce plugin directory..."
53-
ln -s "$WOOCOMMERCE_DIR" woocommerce
54-
5564
# Clean up any existing build
5665
if [ -d "build" ]; then
5766
echo "🧹 Cleaning up existing build..."
@@ -74,8 +83,6 @@ php generate-hook-docs.php
7483
echo ""
7584
echo "βœ… Documentation generated successfully!"
7685
echo "πŸ“ Output location: ./build/api/"
77-
echo "πŸ”— The symbolic link to your WooCommerce directory will remain for future builds."
78-
echo " To remove it: rm woocommerce"
7986
echo ""
8087
echo "🌐 Starting local web server for WooCommerce Code Reference..."
8188
echo "πŸ“ Serving from: ./build/api"

0 commit comments

Comments
Β (0)