summaryrefslogtreecommitdiff
path: root/deps/node/deps/npm/lib/utils/package-id.js
blob: 2c5e3314694c318bb0c45d46f696c003890292a7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
'use strict'
var moduleName = require('./module-name.js')

module.exports = function (tree) {
  var pkg = tree.package || tree
  // FIXME: Excluding the '@' here is cleaning up after the mess that
  // read-package-json makes. =(
  if (pkg._id && pkg._id !== '@') return pkg._id
  var name = moduleName(tree)
  if (pkg.version) {
    return name + '@' + pkg.version
  } else {
    return name
  }
}