Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Initial programmatic API. just ps for now.

  • Loading branch information...
commit 17fb23061256944261ee8dbc2545abac950b840d 1 parent e65c839
@mikeal mikeal authored
Showing with 33 additions and 0 deletions.
  1. +33 −0 index.js
View
33 index.js
@@ -0,0 +1,33 @@
+var argv = require('./lib/argv');
+var propagit = require('propagit');
+var EventEmitter = require('events').EventEmitter;
+
+function Commands (opts) {
+ this.opts = opts
+}
+Commands.prototype.ps = function (cb) {
+ var p = propagit(this.opts);
+ p.on('error', function (err) {
+ cb(err);
+ });
+ p.hub.on('up', function (hub) {
+ var em = new EventEmitter;
+ var obj = {};
+
+ em.on('data', function (key, procs) {
+ obj[key] = procs
+ });
+
+ em.on('end', function () {
+ cb(null, obj)
+ });
+
+ hub.ps(em.emit.bind(em));
+ });
+}
+
+module.exports = function (opts) {
+ return new Commands(opts)
+}
+
+
Please sign in to comment.
Something went wrong with that request. Please try again.