-
-
Save SomeKittens/5a8c40400b13a4a56858 to your computer and use it in GitHub Desktop.
disposer + process exit
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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