Skip to content

Commit e42da31

Browse files
committed
dapp: remappings: use shortest path when deduplicating
1 parent c01b0b5 commit e42da31

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/dapp/libexec/dapp/dapp-remappings

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,11 @@ function deduplicate(pkg) {
5252
// walk tree and build a mapping from hash => path
5353
function mapHashes(pkg) {
5454
const go = (mapping, dep) => {
55-
mapping[dep.hash] = dep.path
55+
// we collect the shortest path (aka closest to the root) for each dep
56+
if (mapping[dep.hash] == undefined || dep.path.length < mapping[dep.hash].length) {
57+
mapping[dep.hash] = dep.path
58+
}
59+
5660
return dep.deps.reduce(go, mapping)
5761
}
5862
return pkg.deps.reduce(go, { [pkg.hash]: pkg.path })

0 commit comments

Comments
 (0)