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

Commit c38df2d

Browse files
committed
Fixes error handling to create a Node Object when a child package is not exist
1 parent 2ed40c4 commit c38df2d

File tree

3 files changed

+14
-2
lines changed

3 files changed

+14
-2
lines changed

rpt.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,12 +78,15 @@ Link.prototype.realpath = ''
7878
function loadNode (logical, physical, cache, cb) {
7979
debug('loadNode', dpath(logical))
8080
fs.realpath(physical, function (er, real) {
81-
if (er) return cb(er)
81+
var node
82+
if (er) {
83+
node = new Node(null, logical, physical, er, cache)
84+
return cb(null, node)
85+
}
8286
debug('realpath l=%j p=%j real=%j', dpath(logical), dpath(physical), dpath(real))
8387
var pj = path.resolve(real, 'package.json')
8488
rpj(pj, function (er, pkg) {
8589
pkg = pkg || null
86-
var node
8790
if (physical === real) {
8891
node = new Node(pkg, logical, physical, er, cache)
8992
} else {

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)