2013-03-07 17:46:17 +00:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
# Upgrade npm package (dev)dependencies to the latest versions and update package.json
|
|
|
|
#
|
|
|
|
# Require:
|
|
|
|
# - jq - brew install jq
|
|
|
|
|
2013-04-02 09:28:15 +00:00
|
|
|
command -v jq >/dev/null 2>&1 || { echo >&2 "jq not installed: see comments for instructions."; exit 1; }
|
|
|
|
|
2013-03-07 17:46:17 +00:00
|
|
|
# Common stuff
|
|
|
|
RED="$(tput setaf 1)"
|
|
|
|
CYAN="$(tput setaf 6)"
|
|
|
|
UNDERLINE="$(tput sgr 0 1)"
|
|
|
|
NOCOLOR="$(tput sgr0)"
|
|
|
|
function header() { echo -e "$UNDERLINE$CYAN$1$NOCOLOR\n"; }
|
|
|
|
function error() { echo -e "$UNDERLINE$RED$1$NOCOLOR"; }
|
|
|
|
|
|
|
|
if [ ! -f package.json ]; then
|
|
|
|
error "package.json not found"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
update() {
|
|
|
|
header "Upgrading $1..."
|
|
|
|
for package in $(cat package.json | jq -r ".$1 | keys | .[]" 2>/dev/null); do
|
|
|
|
npm install --$2 $package
|
|
|
|
done
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
update dependencies save
|
2013-10-23 05:42:28 +00:00
|
|
|
update devDependencies save-dev
|
|
|
|
|
|
|
|
git diff -U0 package.json
|