Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
raineorshine committed Dec 12, 2014
2 parents a41a68f + 23f6db6 commit 57d7cc1
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 3 deletions.
16 changes: 16 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,20 @@ $ npm-check-updates -u
package.json upgraded
```

Check only devDependencies packages for updates:
```
$ npm-check-updates -d
"mocha" can be updated to version 1.12.1
```

Check only production dependencies packages for updates:
```
$ npm-check-updates -p
"request" can be updated from 2.20.x to 2.27.x (Installed: 2.20.0, Latest: 2.27.1)
```

Now simply perform the usual "npm update" and verify that your project
works with the upgraded versions.

Expand All @@ -80,6 +94,8 @@ $ npm-check-updates -f /^((?!gulp-).)*$/
History
--------------

- 1.5
- Add prod and dev only options
- 1.4
- Add package filtering option
- Add mocha as npm test script
Expand Down
6 changes: 5 additions & 1 deletion lib/npm-check-updates.js
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,9 @@ function analyzeProjectDependencies(packageFile) {
async.series({
current: function (callback) {
vm.getCurrentDependencies(packageFile, {
filter: program.filter
filter: program.filter,
prod: program.prod,
dev: program.dev
}, callback);
},
installed: function (callback) {
Expand Down Expand Up @@ -138,6 +140,8 @@ program
.option('-g, --global', 'check global packages instead of in the current project')
.option('-s, --silent', "don't output anything")
.option('-u, --upgrade', 'upgrade package.json dependencies to match latest versions (maintaining existing policy)')
.option('-p, --prod', 'process only dependencies')
.option('-d, --dev', 'process only devDependencies')
.parse(process.argv);

if (program.global && program.upgrade) {
Expand Down
10 changes: 9 additions & 1 deletion lib/versionmanager.js
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,15 @@ function getCurrentDependencies(packageFile, options, callback) {
return callback(new Error('package.json does not contain valid json'))
}

var allDependencies = mergeObjects(json.dependencies, json.devDependencies)
var allDependencies = {};

if (options.prod || !options.dev) {
allDependencies = mergeObjects(allDependencies, json.dependencies);
}

if (options.dev || (!options.prod && !options.dev)) {
allDependencies = mergeObjects(allDependencies, json.devDependencies);
}

if(options.filter) {

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "npm-check-updates",
"version": "1.4.0",
"version": "1.5.0",
"author": "Tomas Junnonen <[email protected]>",
"description": "Find newer versions of dependencies than what your package.json allows",
"keywords": [
Expand Down

0 comments on commit 57d7cc1

Please sign in to comment.