-
Notifications
You must be signed in to change notification settings - Fork 3.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: relativize file links when inflating shrinkwrap
PR-URL: #758 Credit: @jsnajdr Close: #758 Reviewed-by: @ruyadorno
- Loading branch information
Showing
4 changed files
with
36 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,15 @@ | ||
'use strict' | ||
const npa = require('npm-package-arg') | ||
const moduleName = require('../utils/module-name.js') | ||
|
||
const packageRelativePath = require('./deps').packageRelativePath | ||
module.exports = function (child, reqBy) { | ||
if (!child.requiredBy.length) return | ||
if (!reqBy) reqBy = child.requiredBy[0] | ||
const deps = reqBy.package.dependencies || {} | ||
const devDeps = reqBy.package.devDependencies || {} | ||
const optDeps = reqBy.package.optionalDependencies || {} | ||
const name = moduleName(child) | ||
return npa.resolve(name, deps[name] || devDeps[name], reqBy.realpath) | ||
const spec = deps[name] || devDeps[name] || optDeps[name] | ||
const where = packageRelativePath(reqBy) | ||
return npa.resolve(name, spec, where) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters