Desktop notifications on npm publish events
JavaScript Shell
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.


Desktop notifications on npm publish events

Because what you really need is more distractions in your workday!

Currently only works on Linux, perhaps some clever OS X user might contribute code to make it work there too.


$ sudo npm install npm-publish-notify
$ npm-publish-notify &

And off it goes. Bandwidth-usage is fairly low, see npm-publish-stream for details on how it fetches the data.

Example Screenshot


But wait! There's more! You may not want to see all the cruft that gets published to npm, there are a lot of packages after all.

So, implement your own filtering function and pass it as an argument to npm-publish-notify. Your filter function should be an export in a standard Node file. Your function should return a truthy value that will determine whether the package will be let through as a notification. You get the full npm doc to play with.

You'll find a noisy_filter.js example in this repository, it's simply a filter that lets all packages through but it pretty-prints the doc to stdout so you can see what kind of data you can play with. But beware, it is noisy, the whole README of each package is bundled, along with historical version information.


module.exports = function (doc) {
  console.log(JSON.stringify(doc, null, 2))
  return true

Perhaps you want to filter on packages that depend on a particular package you care about?


module.exports = function (doc) {
  var v = doc['dist-tags'] && doc['dist-tags'].latest
  return v && Object.keys(doc.versions[v].dependencies || {}).indexOf('my-special-package') != -1

Or perhaps you care more about keywords?


module.exports = function (doc) {
  var v = doc['dist-tags'] && doc['dist-tags'].latest
  return v && (doc.versions[v].keywords || []).indexOf('awesome') != -1

How about a particular package author?


module.exports = function (doc) {
  var v = doc['dist-tags'] && doc['dist-tags'].latest
  return v && doc.versions[v].maintainers.some(function (m) { return == 'substack' })

Advanced filter examples

Examples of fancier filters for this data can be found here (filter based on package names, keywords, and dependencies) and here (filter based on a defined array of npm maintainer usernames).


npm-publish-notify is Copyright (c) 2013 Rod Vagg @rvagg and licenced under the MIT licence. All rights not explicitly granted in the MIT license are reserved. See the included LICENSE file for more details.