Skip to content
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

fix(husky): grep throws premature termination #3054

Conversation

flacial
Copy link
Member

@flacial flacial commented Jun 11, 2023

Problem

The current issue arises when the grep command fails to find a pattern in a text, resulting in an error code 1. This error is considered an error condition in the husky.sh file, leading to the premature termination of the script.

Solution

To address this problem, my chosen solution is to replace the grep command with git grep. Unlike grep, git grep does not return an exit code of 1 when a pattern is not found. This change ensures that the error condition is no longer triggered, allowing the script to continue execution without premature termination.

While there are alternative approaches to handle this issue, such as using the OR operator to return true when grep -e exits with a code >= 1, or specifically suppressing the error by checking if grep -e returns an exit code of 1, I have opted for the simplicity of using git grep to effectively suppress the error.

Changes

  • Update the variables depsChanged & prismaChanged to use git grep to find the pattern

Related issues

@vercel
Copy link

vercel bot commented Jun 11, 2023

@flacial is attempting to deploy a commit to the c0d3-prod Team on Vercel.

A member of the Team first needs to authorize it.

@vercel
Copy link

vercel bot commented Jun 11, 2023

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
c0d3-app ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jun 11, 2023 11:40am

@codecov
Copy link

codecov bot commented Jun 11, 2023

Codecov Report

Merging #3054 (da261fe) into master (852071d) will not change coverage.
The diff coverage is n/a.

❗ Current head da261fe differs from pull request most recent head 99d1489. Consider uploading reports for the commit 99d1489 to get more accurate results

Impacted file tree graph

@@            Coverage Diff            @@
##            master     #3054   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files          191       191           
  Lines         3615      3615           
  Branches       996       996           
=========================================
  Hits          3615      3615           

@flacial flacial added this pull request to the merge queue Jun 11, 2023
Merged via the queue into garageScript:master with commit a00954b Jun 11, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Husky post-merge hook throws an error
2 participants