From 136b1b0ef6ae0a50134e8e9eaaafa2b7b341ff4f Mon Sep 17 00:00:00 2001 From: Nicolas Brassard Date: Thu, 11 Dec 2014 11:38:11 -0500 Subject: [PATCH 1/3] Added dev-only flag (-d, --dev) This will allow developers to make the check a little bit faster and a bit safer when dealing with only devDeps. Fixes #36 --- lib/npm-check-updates.js | 4 +++- lib/versionmanager.js | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/npm-check-updates.js b/lib/npm-check-updates.js index 6711488d..98f12cd6 100644 --- a/lib/npm-check-updates.js +++ b/lib/npm-check-updates.js @@ -79,7 +79,8 @@ function analyzeProjectDependencies(packageFile) { async.series({ current: function (callback) { vm.getCurrentDependencies(packageFile, { - filter: program.filter + filter: program.filter, + dev: program.dev }, callback); }, installed: function (callback) { @@ -138,6 +139,7 @@ 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('-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..9ef4c021 100644 --- a/lib/versionmanager.js +++ b/lib/versionmanager.js @@ -170,7 +170,7 @@ 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 = options.dev ? json.devDependencies : mergeObjects(json.dependencies, json.devDependencies) if(options.filter) { From 9af2579d37724150f00156a2129dd8fc2e377e03 Mon Sep 17 00:00:00 2001 From: Nicolas Brassard Date: Thu, 11 Dec 2014 13:31:01 -0500 Subject: [PATCH 2/3] Added prod-only flag (-p, --prod) As for the -d flag, this changes makes it possible to only check production dependencies (dependencies field in package.json). This change assumes the following: 1. Include prod if - --prod is on - --dev is off 2. Include dev if - --dev is on - --prod is off and --dev is off That way, we make sure that no options will still include everything and that specifing both --prod and --dev with include both as well. Specifing only one of the two will include the specified option. Re #36 --- lib/npm-check-updates.js | 2 ++ lib/versionmanager.js | 10 +++++++++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/lib/npm-check-updates.js b/lib/npm-check-updates.js index 98f12cd6..f4ecf20f 100644 --- a/lib/npm-check-updates.js +++ b/lib/npm-check-updates.js @@ -80,6 +80,7 @@ function analyzeProjectDependencies(packageFile) { current: function (callback) { vm.getCurrentDependencies(packageFile, { filter: program.filter, + prod: program.prod, dev: program.dev }, callback); }, @@ -139,6 +140,7 @@ 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); diff --git a/lib/versionmanager.js b/lib/versionmanager.js index 9ef4c021..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 = options.dev ? json.devDependencies : 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) { From b6bf3fad87515ac0fde00c3c310a954f6619462a Mon Sep 17 00:00:00 2001 From: Nicolas Brassard Date: Thu, 11 Dec 2014 14:46:58 -0500 Subject: [PATCH 3/3] Version 1.5.0 + documentation This changes create version 1.5.0 It includes relase notes and documentation for the new features (-p and -d) --- README.md | 16 ++++++++++++++++ package.json | 2 +- 2 files changed, 17 insertions(+), 1 deletion(-) 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/package.json b/package.json index 8e781846..8093c4ac 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": [