3 var path = require("path")
4 var dz = require("dezalgo")
5 var npa = require("npm-package-arg")
7 module.exports = function (spec, where, cb) {
8 if (where instanceof Function) { cb = where; where = null }
9 if (where == null) where = "."
17 if ((dep.type == "range" || dep.type == "version") && dep.name != dep.raw) return cb(null, dep)
18 var specpath = dep.type == "local"
19 ? path.resolve(where, dep.spec)
20 : path.resolve(dep.rawSpec? dep.rawSpec: dep.name)
21 fs.stat(specpath, function (er, s) {
22 if (er) return finalize()
23 if (!s.isDirectory()) return finalize("local")
24 fs.stat(path.join(specpath, "package.json"), function (er) {
25 finalize(er ? null : "directory")
28 function finalize(type) {
29 if (type != null && type != dep.type) {
32 dep.rawSpec = dep.name
36 if (dep.type == "local" || dep.type == "directory") dep.spec = specpath