[tooling]: post-checkout git hook
I just snagged the leftover component script for Spectrum and applied it to the post-checkout git hook via husky: https://github.com/adobe/spectrum-web-components/pull/2439
Thought you might be interested in adding the same! I can open a PR if you want.
neat idea. Do you think running the clean script on each checkout would be helpful, too?
Interesting - probably not is my guess. I'm imagining working on some code and creating a new branch to put it in but perhaps don't want it blown away. The hanging folders feels safe because it's just a lonely node_modules with no package.json.
Copying the code here in case the history gets deleted:
.husky/post-checkout
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"
# If this is a file checkout (== 0) exit.
if [ "$3" == "0" ]; then exit; fi
# If this is a branch checkout (== 1) continue...
# For each element, check for a node_modules dir without a corresponding
# package.json. That indicates the element does not exist in this branch.
for e in {packages,projects,tools}/*; do
if [[ -d $e/node_modules && !( -f $e/package.json ) ]]; then
# Safe to delete this folder
rm -rf $e
fi
done
exit 0