Used to determine if a process pid is running from node.js.
expect(1234).to.be.alive;
chai.Assertion.addProperty('alive', function () { | |
new chai.Assertion(this._obj).to.be.a('number'); | |
var alive = true | |
, pid = this._obj; | |
try { process.kill(pid, 0); } | |
catch (ex) { if (ex.code == 'ESRCH') alive = false; } | |
this.assert( | |
alive === true | |
, 'expected pid #{this} to be alive' | |
, 'expected pid #{this} to not be alive' | |
); | |
}); |