package-id.js 399 B

123456789101112131415
  1. 'use strict'
  2. var moduleName = require('./module-name.js')
  3. module.exports = function (tree) {
  4. var pkg = tree.package || tree
  5. // FIXME: Excluding the '@' here is cleaning up after the mess that
  6. // read-package-json makes. =(
  7. if (pkg._id && pkg._id !== '@') return pkg._id
  8. var name = moduleName(tree)
  9. if (pkg.version) {
  10. return name + '@' + pkg.version
  11. } else {
  12. return name
  13. }
  14. }