I've come across the following function in a React project shell script and am quite new to shell scripting so would like to confirm my understanding of it.
In simple english, is the function checking there is a package.json file and then reading that file, I'm not sure what the glob pattern is doing though. The function is being passed a precommit string, so would it match the following? it does seem a bit odd if it matches the 2nd one as well
"precommit":
"precommit" abcde:
has_hook_script () {
[ -f package.json ] && cat package.json | grep -q "\"$1\"[[:space:]]*:"
}