diff --git a/README.md b/README.md index 659d95db..1b105024 100644 --- a/README.md +++ b/README.md @@ -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. @@ -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 diff --git a/lib/npm-check-updates.js b/lib/npm-check-updates.js index 6711488d..f4ecf20f 100644 --- a/lib/npm-check-updates.js +++ b/lib/npm-check-updates.js @@ -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) { @@ -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) { diff --git a/lib/versionmanager.js b/lib/versionmanager.js index 43760b74..c12c70f5 100644 --- a/lib/versionmanager.js +++ b/lib/versionmanager.js @@ -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) { diff --git a/package.json b/package.json index ae595593..51e750a8 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "npm-check-updates", - "version": "1.4.0", + "version": "1.5.0", "author": "Tomas Junnonen ", "description": "Find newer versions of dependencies than what your package.json allows", "keywords": [