Skip to content

Commit

Permalink
Robustify Git-Hooks for use with GitHub Desktop (#499)
Browse files Browse the repository at this point in the history
git: try to make pre-push hook more robust with sourcing npm
  • Loading branch information
EagleoutIce authored Nov 24, 2023
1 parent 5306718 commit 5918e5d
Showing 1 changed file with 25 additions and 4 deletions.
29 changes: 25 additions & 4 deletions .githooks/pre-push
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,30 @@

set -eu

if ! [ -x "$(command -v npm)" ]; then
echo 'Error: npm not found. Make it available to the host shell (e.g., with "nvm use --lts").'
exit 2
NPM_CMD="npm"

if ! (type $NPM_CMD >> /dev/null); then
echo "npm not found, trying to make it available using nvm..."
if type nvm >> /dev/null; then
echo "nvm found, using it to install the latest lts node"
nvm use --lts
else
echo "nvm not found, trying to make it available using the nvm.sh"
# try to make it available based on https://github.com/typicode/husky/issues/912#issuecomment-817522060
export NVM_DIR="$HOME/.nvm/nvm.sh"
. "$(dirname $NVM_DIR)/nvm.sh"

export NVM_DIR="$HOME/.nvm"
a=$(nvm ls --no-colors | grep 'node')
v=$(echo "$a" | sed -E 's/.*\(-> ([^ ]+).*/\1/')

export PATH="$NVM_DIR/versions/node/$v/bin:$PATH"

if ! (type $NPM_CMD >> /dev/null); then
echo "no variant of npm or nvm found, trying to use the npm.cmd"
NPM_CMD="npm.cmd"
fi
fi
fi


Expand Down Expand Up @@ -37,7 +58,7 @@ if [ -n "$(git status --porcelain)" ]; then
fi

echo "Linting project (local mode)..."
npm run lint-local
$NPM_CMD run lint-local


# shellcheck disable=SC2124 # we want the argument splitting
Expand Down

2 comments on commit 5918e5d

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"artificial" Benchmark Suite

Benchmark suite Current: 5918e5d Previous: c209d78 Ratio
Total per-file 3180.627769 ms (3666.697758580956) 3354.2152301363635 ms (3860.1297956846133) 0.95
Retrieve AST from R code 66.86315895454545 ms (132.98632377576763) 71.48860922727273 ms (136.54310977165716) 0.94
Normalize R AST 93.74252859090909 ms (151.71314235488452) 95.79139172727274 ms (152.52195436786488) 0.98
Produce dataflow information 64.90969395454545 ms (167.82737821068204) 66.23299468181818 ms (170.60548403093352) 0.98
Total per-slice 1.8488863393048989 ms (1.2743065575533874) 1.8581676256634037 ms (1.2492897864296644) 1.00
Static slicing 1.381659656207502 ms (1.1911144702425194) 1.372047543536089 ms (1.1480006540491348) 1.01
Reconstruct code 0.44959999027314657 ms (0.218216468628543) 0.46882655148163743 ms (0.2603715463019149) 0.96
failed to reconstruct/re-parse 0 # 0 # NaN
times hit threshold 0 # 0 # NaN
reduction (characters) 0.7329390759026896 # 0.7329390759026896 # 1
reduction (normalized tokens) 0.720988345209971 # 0.720988345209971 # 1

This comment was automatically generated by workflow using github-action-benchmark.

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"social-science" Benchmark Suite

Benchmark suite Current: 5918e5d Previous: c209d78 Ratio
Total per-file 5161.365818560001 ms (5799.408262298838) 5464.289228619999 ms (6098.39318648839) 0.94
Retrieve AST from R code 75.28840504 ms (65.87849757414983) 86.76445109999999 ms (77.45681339952834) 0.87
Normalize R AST 110.4939551 ms (67.41871707177987) 113.78691086 ms (69.64981912121678) 0.97
Produce dataflow information 162.08470576 ms (273.81782487526453) 166.90590034000002 ms (285.57711744755056) 0.97
Total per-slice 8.438030530073512 ms (14.079298292704003) 8.863963769870134 ms (14.566635289387673) 0.95
Static slicing 7.947892706099781 ms (13.965640258279858) 8.249822291669334 ms (14.448470605228648) 0.96
Reconstruct code 0.4817788068475808 ms (0.2376493795459932) 0.6040326772298797 ms (0.31033593750624766) 0.80
failed to reconstruct/re-parse 9 # 9 # 1
times hit threshold 967 # 967 # 1
reduction (characters) 0.898713819973478 # 0.898713819973478 # 1
reduction (normalized tokens) 0.8579790415512589 # 0.8579790415512589 # 1

This comment was automatically generated by workflow using github-action-benchmark.

Please sign in to comment.