Update your devDependencies and dependencies automatically with a grunt task
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 --save-dev grunt-dev-update
The best way to load tasks is probably using load-grunt-tasks
npm install --save-dev load-grunt-tasks
And then add to your gruntfile.js:
The "devUpdate" task
This plugin allows you to both update your dependencies and devDependencies with an automated task.
- See outdated packages
- Choose whether to just get notified, update them with a prompt, or automatically update them.
- Determine whether to stay with semver rules when updating, or to update to latest version.
- Update either or both your devDependencies and dependencies
Q: Why not use
npm update or
A: First, npm update doesn't work on dev dependencies. Second, npm update stays inside your semver matching in your package.json, thirdly - npm isn't automated like your grunt tasks.
In your project's Gruntfile, add a task config named
devUpdate to the data object passed into
Whether to report an already updated package
How devUpdate should handle the outdated packages. Valid options:
report- Just report that the package is outdated.
prompt- Prompt user to confirm update of every package
force- Automatically force the update for the outdated packages.
fail- Fail task if an outdated package was found.
What kind of packages should be checked. Valid options:
dependencies- Specify true to check production dependencies.
Outdated dependencies are installed using the
devDependencies- Specify true to check development dependencies. This is true by default.
Outdated devDependencies are installed using the
true - Packages will be updated with
npm update and will be installed up to your allowed version in
package.json. Your allowed version is determined using semver.
false - Packages will be updated to the latest version there is, regardless of your
Warning - this could break packages and only use this option if you're sure of what you're doing.
This option allow you to manually configure the path of your package.json. Valid options:
null- This will use
matchdepown logic for finding your package.json (using
findupto find nearest package.json). This is the recommended and default option.
String- specify a relative path from your process.cwd() to find your package.json.
Object- pass in an object representing your package.json
For better understanding the
Object option, please see matchdep config.
Specify packages that will be checked for newer version but only reported if outdated.
This is useful if you are aware of packages that will be outdated, but don't want to update them.
Example usage with all options specified with defaults:
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.
MIT @Gilad Peleg