Skip to content

Instantly share code, notes, and snippets.

@SomeKittens

SomeKittens/a.js Secret

Created January 3, 2015 21:33
Show Gist options
  • Save SomeKittens/5a8c40400b13a4a56858 to your computer and use it in GitHub Desktop.
Save SomeKittens/5a8c40400b13a4a56858 to your computer and use it in GitHub Desktop.
disposer + process exit
module.exports = function(fn, exit) {
var close;
return pg.connectAsync(connString).bind({}).spread(function(client, _close) {
close = _close;
return fn(client);
}).catch(console.log).finally(function() {
if (close) {
close();
}
if (exit) {
process.exit();
}
});
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment