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

Commit

Permalink
install/deps: Let git deps w/ lock only match package.json
Browse files Browse the repository at this point in the history
Previously they would only match if the complete commitid was used.  This
allows partial matching when no on-disk component is available.

Fixes: #16839

PR-URL: #20390
Credit: @iarna
Reviewed-By: @zkat
  • Loading branch information
iarna committed May 5, 2018
1 parent 6e767d7 commit 268f7ac
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
10 changes: 10 additions & 0 deletions lib/install/deps.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,16 @@ function doesChildVersionMatch (child, requested, requestor) {
return path.relative(child.realpath, requested.fetchSpec) === ''
}

if (requested.type === 'git' && child.fromShrinkwrap) {
const fromSw = child.fromShrinkwrap

if (fromSw.rawSpec === requested.rawSpec) return true

if (!fromSw.hosted || !requested.hosted) return false

return fromSw.hosted.toString() === requested.hosted.toString()
}

if (!registryTypes[requested.type]) {
var childReq = child.package._requested
if (childReq) {
Expand Down
2 changes: 1 addition & 1 deletion lib/install/inflate-shrinkwrap.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ function inflatableChild (onDiskChild, name, topPath, tree, sw, requested, opts)
const modernLink = requested.type === 'directory' && !sw.from
if (hasModernMeta(onDiskChild) && childIsEquivalent(sw, requested, onDiskChild)) {
// The version on disk matches the shrinkwrap entry.
if (!onDiskChild.fromShrinkwrap) onDiskChild.fromShrinkwrap = true
if (!onDiskChild.fromShrinkwrap) onDiskChild.fromShrinkwrap = requested
onDiskChild.package._requested = requested
onDiskChild.package._spec = requested.rawSpec
onDiskChild.package._where = topPath
Expand Down

0 comments on commit 268f7ac

Please sign in to comment.