Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
// now we know it's not a URL or file,
// so handle it like a tag, version, or range.
pkg = pkg.split("@");
var name = pkg[0],
defTag = npm.config.get("tag"),
ver = pkg.slice(1).join("@").trim() || defTag,
range = semver.validRange(ver),
exact = semver.valid(ver),
tag = !exact && !range && range !== "" && ver,
pkg = pkg.join("@");
// at this point, assume that it has to be debianized
if (exact) {
log.verbose("exact", pkg);
// just pull the data out of the cache to ensure it's there
return cache.read(name, ver, finisher(pkg, reg, pkglist, cb));
}
getData(name, function (er, data) {
if (er) return cb(er);
log.silly(data, pkg);
if (tag) {
log.verbose(tag, pkg + " tag");
var tags = data["dist-tags"];
if (!tags[tag]) return log.er(cb, "Tag not found: " + data.name + "@" + tag)(er);
_source(data.name + "@" + tags[tag], reg, pkglist, cb);
} else {
log.verbose(tag, pkg + " range");
// prefer the default tag version.
var defTag = npm.config.get("tag"), satis;
defTag = defTag && data["dist-tags"] && data["dist-tags"][defTag];
if (semver.satisfies(defTag, range)) satis = defTag;
unpack(pkg, ver, debianPackageDir, function(err) {
if (err) throw err;
// read package data
cache.read(pkg, ver, function(err, packageData) {
if (err) throw err;
ctx.packageData = packageData;
ctx.shortdesc = packageData.description || '';
ctx.longdesc = 'This is a debianized npm package';
var deps = [],
nodeVer = (packageData && packageData.engines && packageData.engines.node) ? semver.clean(packageData.engines.node) : null;
nodeVer = (nodeVer && nodeVer != '*') ? '(' + packageData.engines.node + ')' : '(>= ' + semver.clean(process.version) + ')';
deps = ['nodejs ' + nodeVer];
if (packageData.dependencies) {
for (var dep in packageData.dependencies) {
deps.push(ctx.debianNamePrefix + dep + ' (' + packageData.dependencies[dep] + ')');
}
ctx.depends = deps.join(', ');
, exact = semver.valid(ver)
, tag = !exact && !range && range !== "" && ver
log.verbose([pkg, mustHave], "must install?")
pkg = pkg.join("@")
seen[name+"@"+ver] = true
// if there is a satisfying version already, then simply move on.
if (!tag && findSatisfying(pkg, name, range, mustHave, reg)) {
return cb()
}
// at this point, assume that it has to be installed.
if (exact) {
log.verbose("exact", pkg)
// just pull the data out of the cache to ensure it's there
return cache.read(name, ver, finisher(pkg, reg, pkglist, cb))
}
getData(name, function (er, data) {
if (er) return cb(er)
log.silly(data, pkg)
if (tag) {
log.verbose(tag, pkg+" tag")
var tags = data["dist-tags"]
if (!tags[tag]) return log.er(cb, "Tag not found: "+data.name+"@"+tag)(er)
install_(data.name+"@"+tags[tag], reg, seen, mustHave, pkglist, cb)
} else {
log.verbose(tag, pkg+" range")
// prefer the default tag version.
var defTag = npm.config.get("tag")
, satis
defTag = defTag && data["dist-tags"] && data["dist-tags"][defTag]
function unpack (pkg, ver, unpackTarget, cb) {
cache.read(pkg, ver, function (er, data) {
if (er) return log.er(cb, "Could not read data for "+pkg+"@"+ver)(er);
unpackTar(path.join(npm.cache, pkg, ver, "package.tgz"), unpackTarget, cb);
})
}