Configure

Set up in your shell config, such as .bashrc, .zshrc, or .aliases.

alias git-deps='git commit . -m "build(deps): upgrade packages"'

# Upgrade packages and commit them.
# Remember verify changes afterwards using a build or server command, or `git
# push` and a hook.
upgrade() {
  if [[ -n "$(git status --porcelain)" ]]; then
    echo 'ERROR: Working tree is not clean'

    return 1
  fi

  make upgrade

  if [[ -z "$(git status --porcelain)" ]]; then
    echo 'No upgrade changes to commit'

    return
  fi

  git-deps
}

If you don’t use make, then replace make upgrade with your appropriate command.

e.g.

  • NPM
      npm update
    
  • Yarn
      yarn upgrade
    
  • Ruby and Bundler
      bundle update
    

Usage

Run this:

$ make upgrade

And test your app with commands like:

$ make build
$ make serve
$ git push

Replace your own commands like npm run build.

If upgrade specific package like with npm install eslint@latest, then you can commit that change with this:

$ git-deps

Assuming you don’t have any unrelated change that would get unintentionally committed too.