-
Notifications
You must be signed in to change notification settings - Fork 197
fix: remove jq from vercel script #2135
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
The latest updates on your projects. Learn more about Vercel for GitHub.
|
🌿 Documentation Preview
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR removes the dependency on jq
from the Vercel build script by replacing JSON parsing with native shell utilities. The change addresses the issue that jq
is not available in the Vercel build environment.
- Replaces
jq
JSON parsing withgrep
andsed
commands - Adds error handling for GitHub API responses
- Maintains the same functionality for extracting the PR base branch
if [ -z "$PR_RESPONSE" ]; then | ||
echo "⚠️ No response from GitHub API" | ||
elif echo "$PR_RESPONSE" | grep -q '"message"'; then | ||
ERROR_MSG=$(echo "$PR_RESPONSE" | grep -o '"message":"[^"]*"' | sed 's/"message":"\([^"]*\)"/\1/') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The regex pattern for extracting error messages is fragile and may break if the JSON contains escaped quotes or other special characters within the message string. Consider using a more robust approach or adding validation to handle edge cases.
ERROR_MSG=$(echo "$PR_RESPONSE" | grep -o '"message":"[^"]*"' | sed 's/"message":"\([^"]*\)"/\1/') | |
ERROR_MSG=$(echo "$PR_RESPONSE" | python3 -c 'import sys, json; print(json.load(sys.stdin).get("message", ""))') |
Copilot uses AI. Check for mistakes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
stick with grep/sed, since python env is much less certain and can change with version
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
approved assuming you saw copilot's comment & aren't concerned
Pull Request Checklist
yarn test
)site
folder, and guidelines for updating/adding docs can be found in the contribution guide)feat!: breaking change
)yarn lint:check
) and fix any issues? (yarn lint:write
)PR-Codex overview
This PR updates the
scripts/vercel-ignore-build.sh
script to improve error handling when fetching pull request information from the GitHub API, replacingjq
withgrep
andsed
for compatibility with Vercel's environment.Detailed summary
jq
withgrep
andsed
to parse JSON response.base.ref
from the JSON response usinggrep
andsed
.