Skip to content

Commit

Permalink
Update merge Script
Browse files Browse the repository at this point in the history
  • Loading branch information
jdauphant committed Mar 20, 2023
1 parent 4a5ed6e commit 0027c73
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions scripts/merge-patches.sh
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ function merge_patches() {
# Create a subfolder for the current package inside the temporary directory
PACKAGE_TEMP_DIR="$TEMP_DIR/$PATCH_DIR"
mkdir -p "$PACKAGE_TEMP_DIR"
LOG_FILE=$PACKAGE_TEMP_DIR/result.log
LOG_FILE="$PACKAGE_TEMP_DIR".log

# Install the package in the package subfolder
cd "$PACKAGE_TEMP_DIR"
Expand All @@ -54,7 +54,7 @@ function merge_patches() {
yarn patch-package "$PACKAGE_NAME" > $LOG_FILE 2>&1

# Move the new patch file to the old patch file's location
mv patches/"$PACKAGE_NAME"*.patch "$(dirname $PATCH_PATH)"
mv patches/*.patch "$(dirname $PATCH_PATH)"
rm $PATCH_PATH

# Clean up the package subfolder
Expand All @@ -78,11 +78,12 @@ function continue_patches() {

# Iterate through the package subfolders
for PACKAGE_TEMP_DIR in "$TEMP_DIR"/*; do
echo "# Manage $PATCH_PATH"
PATCH_DIR="$PATCHES_DIR/$(basename "$PACKAGE_TEMP_DIR")"
PATCH_PATH="$PATCH_DIR"/*.patch
PATCH_FILE=$(basename $PATCH_PATH)
PATCH_FILE=$(basename $PATCH_PATH)
PACKAGE_NAME=$(echo "$PATCH_FILE" | cut -d'+' -f1)
LOG_FILE="$PACKAGE_TEMP_DIR".log
echo "# Manage $PATCH_PATH"

# Check for conflicts
CONFLICTS=$(grep -lr "<<<<<<<" "$PACKAGE_TEMP_DIR/node_modules/$PACKAGE_NAME") || true
Expand All @@ -97,14 +98,16 @@ function continue_patches() {
else
# If there are no conflicts, generate a new patch file
cd "$PACKAGE_TEMP_DIR"
yarn patch-package "$PACKAGE_NAME"
yarn patch-package "$PACKAGE_NAME" 2>&1 > $LOG_FILE || true

# Move the new patch file to the old patch file's location
mv patches/"$PACKAGE_NAME"*.patch "$(dirname $PATCH_PATH)"
mv patches/*.patch "$(dirname $PATCH_PATH)"
rm $PATCH_PATH

# Clean up the package subfolder
cd "$TEMP_DIR"
rm -rf "$(basename "$PACKAGE_TEMP_DIR")"
echo "Patch Done and temp file cleaned"
fi
done

Expand Down

0 comments on commit 0027c73

Please sign in to comment.