Skip to content
This repository has been archived by the owner on Aug 11, 2022. It is now read-only.

Commit

Permalink
outdated: Ensure errors reading the package tree do not crash
Browse files Browse the repository at this point in the history
Fixes: #13115
Credit: @iarna
Reviewed-By: @othiym23
PR-URL: #13121
  • Loading branch information
iarna committed Jun 20, 2016
1 parent fbefb86 commit 6a33b2c
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
1 change: 1 addition & 0 deletions lib/outdated.js
Expand Up @@ -76,6 +76,7 @@ function outdated (args, silent, cb) {
if (npm.config.get('depth') === Infinity) npm.config.set('depth', 0)

readPackageTree(dir, andRecalculateMetadata(function (er, tree) {
if (!tree) return cb(er)
mutateIntoLogicalTree(tree)
outdated_(args, '', tree, {}, 0, function (er, list) {
list = uniq(list || []).sort(function (aa, bb) {
Expand Down
21 changes: 21 additions & 0 deletions test/tap/outdated-bad-read-tree.js
@@ -0,0 +1,21 @@
'use strict'
var test = require('tap').test
var requireInject = require('require-inject')
var npm = require('../../lib/npm.js')

test('setup', function (t) {
npm.load({progress: false}, t.end)
})

test('outdated', function (t) {
var rptError = new Error('read-package-tree')
var outdated = requireInject('../../lib/outdated.js', {
'read-package-tree': function (dir, cb) {
cb(rptError)
}
})
outdated([], function (err) {
t.is(err, rptError)
t.end()
})
})

0 comments on commit 6a33b2c

Please sign in to comment.