diff --git a/lib/outdated.js b/lib/outdated.js index 794197cfc6a69..5b84ae35587c8 100644 --- a/lib/outdated.js +++ b/lib/outdated.js @@ -91,7 +91,7 @@ function outdated (args, silent, cb) { var dir = path.resolve(npm.dir, '..') // default depth for `outdated` is 0 (cf. `ls`) - if (opts.depth) opts = opts.concat({depth: 0}) + if (opts.depth === Infinity) opts = opts.concat({depth: 0}) readPackageTree(dir, andComputeMetadata(function (er, tree) { if (!tree) return cb(er) diff --git a/test/tap/outdated-depth.js b/test/tap/outdated-depth.js index 5cf7c7edac9c4..c3d87c64ce0e4 100644 --- a/test/tap/outdated-depth.js +++ b/test/tap/outdated-depth.js @@ -47,6 +47,7 @@ test('outdated depth zero', function (t) { mr({ port: common.port }, function (er, s) { npm.load( { + depth: 0, loglevel: 'silent', registry: common.registry }, @@ -54,12 +55,22 @@ test('outdated depth zero', function (t) { npm.install('.', function (er) { if (er) throw new Error(er) npm.outdated(function (err, d) { - t.ifError(err, 'npm outdated ran without error') + if (err) { + throw err + } t.is(process.exitCode, 1, 'exit code set to 1') process.exitCode = 0 t.deepEqual(d[0], expected) - s.close() - t.end() + t.equal(d.length, 1) + npm.config.set('depth', 1) + npm.outdated(function (err, d) { + t.equal(d.length, 2) + if (err) { + throw err + } + s.close() + t.end() + }) }) }) }