Skip to content
This repository was archived by the owner on Jan 7, 2022. It is now read-only.

Commit 1592a19

Browse files
committed
Fixes error handling to create a Node Object when a child package is not exist
1 parent eb24d25 commit 1592a19

File tree

3 files changed

+14
-1
lines changed

3 files changed

+14
-1
lines changed

rpt.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,11 @@ function loadNode (logical, physical, cache, cb) {
9898

9999
var realpath
100100
function thenReadPackageJson (er, real) {
101-
if (er) return cb(er)
101+
var node
102+
if (er) {
103+
node = new Node(null, logical, physical, er, cache)
104+
return cb(null, node)
105+
}
102106
debug('realpath l=%j p=%j real=%j', dpath(logical), dpath(physical), dpath(real))
103107
var pj = path.join(real, 'package.json')
104108
realpath = real

test/basic.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,14 @@ test('missing folder', function (t) {
123123
t.end()
124124
})
125125
})
126+
test('missing symlinks', function (t) {
127+
rpt(path.resolve(fixtures, 'badlink'), function (er, d) {
128+
if (er && er.code !== 'ENOENT') throw er
129+
var childError = d.children.length === 1 && d.children[0].error
130+
t.ok(childError, 'Child node has an error')
131+
t.end()
132+
})
133+
})
126134

127135

128136
function archyize (d, seen) {

test/fixtures/badlink/node_modules/foo

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)