π
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
for dep in $(jq -r ".dependencies | keys | .[]" package.json); do | |
if ! grep "from .*$dep.*" -Rq --exclude-dir="node_modules" .; then | |
echo "you can probably remove $dep" | |
fi | |
done |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# capture info messages and any errors in a log file | |
exec >> log/hooks-out.log 2>&1 | |
if git diff-tree --name-only --no-commit-id ORIG_HEAD HEAD | grep -q 'package.json'; then | |
echo "$(date): reinstalling deps since package.json changed" | |
yarn > /dev/null | |
else | |
echo "$(date): no changes detected in package.json" | |
fi |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
`use strict` | |
const { isArray } = Array | |
const deepFlatten = (array) => { | |
if (!isArray(array)) { | |
throw new Error(`Expecting array to process, instead got ${typeof array}.`) | |
} | |
return array.reduce((accumulator, element) => | |
[ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
PACKAGES_TO_UPDATE=() | |
function get_major_version { echo $(echo $1 | grep -o -E '^[0-9]{1,2}'); } | |
# https://stackoverflow.com/questions/1527049/how-can-i-join-elements-of-an-array-in-bash | |
function join_by { local d=$1; shift; echo -n "$1"; shift; printf "%s" "${@/#/$d}"; } | |
{ | |
while read package current wanted latest location | |
do |