diff --git a/.githooks/pre-push b/.githooks/pre-push index c26900c..213d668 100755 --- a/.githooks/pre-push +++ b/.githooks/pre-push @@ -55,7 +55,7 @@ if [[ ! -f "$PACKAGE_JSON" ]]; then fi # Extract current version using portable tools -CURRENT_VERSION=$(grep -o '"version"[[:space:]]*:[[:space:]]*"[^"]*"' "$PACKAGE_JSON" | head -1 | sed 's/.*"\([0-9][0-9]*\.[0-9][0-9]*\.[0-9][0-9]*\)".*/\1/') +CURRENT_VERSION=$(grep -o '"version"[[:space:]]*:[[:space:]]*"[^"]*"' "$PACKAGE_JSON" | head -1 | sed 's/.*"\([0-9][0-9]*\.[0-9][0-9]*\.[0-9][0-9]*\).*/\1/') if [[ -z "$CURRENT_VERSION" ]]; then log_error "Could not parse version from package.json" @@ -74,10 +74,10 @@ log_info "Pushing to $BRANCH - bumping version: $CURRENT_VERSION -> $NEW_VERSION # Update package.json (preserve formatting, just replace version) if [[ "$(uname)" == "Darwin" ]]; then # macOS sed requires empty string for -i - sed -i '' "s/\"version\"[[:space:]]*:[[:space:]]*\"$CURRENT_VERSION\"/\"version\": \"$NEW_VERSION\"/" "$PACKAGE_JSON" + sed -i '' "s/\"version\"[[:space:]]*:[[:space:]]*\"$CURRENT_VERSION[^\"]*\"/\"version\": \"$NEW_VERSION\"/" "$PACKAGE_JSON" else # GNU sed - sed -i "s/\"version\"[[:space:]]*:[[:space:]]*\"$CURRENT_VERSION\"/\"version\": \"$NEW_VERSION\"/" "$PACKAGE_JSON" + sed -i "s/\"version\"[[:space:]]*:[[:space:]]*\"$CURRENT_VERSION[^\"]*\"/\"version\": \"$NEW_VERSION\"/" "$PACKAGE_JSON" fi log_info "Updated $PACKAGE_JSON"