Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
zkat committed Jan 30, 2019
1 parent 3c5f680 commit be8274e
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 9 deletions.
10 changes: 3 additions & 7 deletions lib/install.js
Original file line number Diff line number Diff line change
Expand Up @@ -825,14 +825,10 @@ Installer.prototype.printInstalledForHuman = function (diffs, auditResult) {
var report = ''
if (this.args.length && (added || updated)) {
report += this.args.map((p) => {
const isAlias = p._requested.type === 'alias'
const name = isAlias
? p._requested.name
: p.name
return `+ ${name}@${isAlias ? `npm:${p.name}@` : ''}${p.version}${
p._requested.name === p.name || isAlias
return `+ ${p.name}@${p.version}${
!p._requested.name || p._requested.name === p.name
? ''
: ` (as node_modules/${p._requested.name})`
: ` (as ${p._requested.name})`
}`
}).join('\n') + '\n'
}
Expand Down
4 changes: 2 additions & 2 deletions lib/install/deps.js
Original file line number Diff line number Diff line change
Expand Up @@ -294,12 +294,12 @@ function computeVersionSpec (tree, child) {
var childReq = child.package._requested
if (child.isLink) {
requested = npa.resolve(moduleName(child), 'file:' + child.realpath, getTop(tree).path)
} else if (child.name && child.name !== child.package.name) {
requested = npa.resolve(child.name, `npm:${child.package.name}@${child.package.version})`)
} else if (childReq && (isNotEmpty(childReq.saveSpec) || (isNotEmpty(childReq.rawSpec) && isNotEmpty(childReq.fetchSpec)))) {
requested = child.package._requested
} else if (child.package._from) {
requested = npa(child.package._from, tree.path)
} else if (child.name && child.name !== child.package.name) {
requested = npa.resolve(child.name, `npm:${child.package.name}@${child.package.version})`)
} else {
npa.resolve(child.package.name, child.package.version)
}
Expand Down
13 changes: 13 additions & 0 deletions lib/ls.js
Original file line number Diff line number Diff line change
Expand Up @@ -555,3 +555,16 @@ function makeParseable_ (data, long, dir, depth, parent, d) {
(data.peerInvalid ? ':PEERINVALID' : '') +
(data.peerMissing ? ':PEERINVALID:MISSING' : '')
}

function physicalName (data) {
if (!data._location) {
return data.name
} else {
const match = data._location.match(/(?:@[^/\\]+[/\\])?[^/\\]+$/i)
if (match) {
return match[0]
} else {
return data.name
}
}
}

0 comments on commit be8274e

Please sign in to comment.