summaryrefslogtreecommitdiff
path: root/deps/npm/lib/install/realize-shrinkwrap-specifier.js
blob: 91030bfa826fe2bda7c69798e37453ec7cb168cb (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
'use strict'
var npa = require('npm-package-arg')

module.exports = function (name, sw, where) {
  try {
    if (sw.version && sw.integrity) {
      return npa.resolve(name, sw.version, where)
    }
    if (sw.resolved) {
      return npa.resolve(name, sw.resolved, where)
    }
    if (sw.from) {
      var spec = npa(sw.from, where)
      if (!spec.registry) return spec
    }
  } catch (_) { }
  return npa.resolve(name, sw.version, where)
}