has-modern-meta.js 702 B

1234567891011121314151617181920
  1. 'use strict'
  2. module.exports = hasModernMeta
  3. const npa = require('npm-package-arg')
  4. const moduleName = require('../utils/module-name.js')
  5. function isLink (child) {
  6. return child.isLink || (child.parent && isLink(child.parent))
  7. }
  8. function hasModernMeta (child) {
  9. if (!child) return false
  10. const resolved = child.package._resolved && npa.resolve(moduleName(child), child.package._resolved)
  11. const version = npa.resolve(moduleName(child), child.package.version)
  12. return child.isTop ||
  13. isLink(child) ||
  14. child.fromBundle || child.package._inBundle ||
  15. child.package._integrity || child.package._shasum ||
  16. (resolved && resolved.type === 'git') || (version && version.type === 'git')
  17. }