realize-shrinkwrap-specifier.js 621 B

12345678910111213141516171819202122
  1. 'use strict'
  2. var npa = require('npm-package-arg')
  3. const isRegistry = require('../utils/is-registry.js')
  4. module.exports = function (name, sw, where) {
  5. try {
  6. if (sw.version && sw.integrity) {
  7. return npa.resolve(name, sw.version, where)
  8. } else if (sw.from) {
  9. const spec = npa(sw.from, where)
  10. if (isRegistry(spec) && sw.version) {
  11. return npa.resolve(name, sw.version, where)
  12. } else if (!sw.resolved) {
  13. return spec
  14. }
  15. }
  16. if (sw.resolved) {
  17. return npa.resolve(name, sw.resolved, where)
  18. }
  19. } catch (_) { }
  20. return npa.resolve(name, sw.version, where)
  21. }