Skip to content

Commit

Permalink
add view for showing scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
isaacs committed Mar 20, 2011
1 parent 7908838 commit bb07329
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions registry/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,28 @@ ddoc.views.listAll = {
map : function (doc) { return emit(doc._id, doc) }
}

ddoc.views.scripts = {
map : function (doc) {
if (!doc || !doc.versions || !doc["dist-tags"]) return
var v = doc["dist-tags"].latest
if (!doc.versions[v]) return
if (!doc.versions[v].scripts) return
emit(doc._id, doc.versions[v].scripts)
}
}

ddoc.lists.scripts = function (head, req) {
var row
, out = {}
while (row = getRow()) {
if (!row.id) continue
if (req.query.package && row.id !== req.query.package) continue
if (req.query.script && !row.value[req.query.script]) continue
out[row.id] = row.value
}
send(toJSON(out))
}

ddoc.views.nodeWafInstall = {
map : function (doc) {
if (!doc || !doc.versions || !doc["dist-tags"]) return
Expand Down

0 comments on commit bb07329

Please sign in to comment.