Skip to content

Commit

Permalink
Don't override user specified depth in outdated
Browse files Browse the repository at this point in the history
Restores ability to update packages using `--depth` as suggested by `npm audit`.

i.e `npm update eslint-utils --depth 2`.

PR-URL: #239
Credit: @G-Rath
Close: #239
Reviewed-by: @claudiahdz
  • Loading branch information
G-Rath authored and claudiahdz committed Aug 30, 2019
1 parent bd6e5d2 commit 235ed1d
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 4 deletions.
2 changes: 1 addition & 1 deletion lib/outdated.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
17 changes: 14 additions & 3 deletions test/tap/outdated-depth.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,19 +47,30 @@ test('outdated depth zero', function (t) {
mr({ port: common.port }, function (er, s) {
npm.load(
{
depth: 0,
loglevel: 'silent',
registry: common.registry
},
function () {
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()
})
})
})
}
Expand Down

0 comments on commit 235ed1d

Please sign in to comment.