Ever accidentally run a grunt deployment task, forgetting that you're actually in a half-working feature branch? Had a colleague ask for help, only to discovery (much later) that they deployed to staging with uncommitted local changes?
This plugin runs a few quick sanity checks to help avoid these problems. It will:
- Allow you to configure a grunt task that will cause grunt to quit if a configured set of checks don't pass
- Optionally check for uncommitted local changes
- Optionally check to ensure there are no local revisions that need to be pushed to the remote
- Optionally check that your local repo is not behind the remote
This plugin requires Grunt
If you haven't used Grunt before, be sure to check out the Getting Started guide, as it explains how to create a Gruntfile as well as install and use Grunt plugins. Once you're familiar with that process, you may install this plugin with this command:
npm install grunt-gitcheck --save-dev
The "gitcheck" task
In your project's Gruntfile, add a section named
gitcheck to the data object passed into
options.branchChecking set to
true, the task will look for a configured array of allowed
branches below), and throw an error if you're not currently working in one of the
With this option set to
true, the task will check to see if you have any local changes that haven't
been committed, and throws an error if you do.
This causes the task to check against the origin to see if your local repo is ahead (you have local revs that have not been pushed) or behind (there are revs at the origin you have not pulled).
true, the task will check against this list of branch names - if
working in a branch not listed in the array when the task is called, an error will be thrown.
In lieu of a formal styleguide, take care to maintain the existing coding style. Add unit tests for any new or changed functionality. Lint and test your code using Grunt.
0.1.0 Initial release