diff options
Diffstat (limited to 'deps/npm/node_modules/npm-registry-client/lib/star.js')
-rw-r--r-- | deps/npm/node_modules/npm-registry-client/lib/star.js | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/deps/npm/node_modules/npm-registry-client/lib/star.js b/deps/npm/node_modules/npm-registry-client/lib/star.js new file mode 100644 index 00000000000..36a66127e50 --- /dev/null +++ b/deps/npm/node_modules/npm-registry-client/lib/star.js @@ -0,0 +1,29 @@ + +module.exports = star + +function star (package, starred, cb) { + if (!this.username) return cb(new Error( + "Must be logged in to star/unstar packages")) + + var users = {} + + this.request("GET", package, function (er, fullData) { + if (er) return cb(er) + + fullData = { _id: fullData._id + , _rev: fullData._rev + , users: fullData.users || {} } + + if (starred) { + this.log.info("starring", fullData._id) + fullData.users[this.username] = true + this.log.verbose("starring", fullData) + } else { + delete fullData.users[this.username] + this.log.info("unstarring", fullData._id) + this.log.verbose("unstarring", fullData) + } + + return this.request("PUT", package, fullData, cb) + }.bind(this)) +} |