Last active
November 28, 2021 12:33
-
-
Save Fraasi/9740ab7500e24caf06cb177ec5c89641 to your computer and use it in GitHub Desktop.
small bash script to print out command to update all (dev)dependencies from package.json to @latest
This file contains 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
#!/bin/bash | |
USAGE="Usage: | |
npm-update-all | |
-> prints all dependencies | |
-d | |
-> prints all devDependencies | |
from current dirs package.json | |
in a ready list to copy paste | |
& update all dependencies to @latest" | |
echo '' | |
if ! command -v jq &>/dev/null; then | |
echo "jq must be installed and in PATH to run this script" | |
echo "https://stedolan.github.io/jq/download/" | |
exit 1 | |
fi | |
if [[ ! -f ./package.json ]]; then | |
echo "no package.json found in current directory" | |
echo "$USAGE" | |
exit 1 | |
fi | |
if [[ -z $1 ]]; then | |
echo "npm install $(jq -j '.dependencies | keys | join("@latest ")' package.json)@latest" | |
fi | |
case $1 in | |
-d) | |
echo "npm install -D $(jq -j '.devDependencies | keys | join("@latest ")' package.json)@latest" | |
;; | |
*) | |
echo "$USAGE" | |
;; | |
esac |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment