Skip to content

Conversation

@jeromew
Copy link

@jeromew jeromew commented Jun 27, 2014

Hello,

I am trying to use db-meta for postgres, but only via exports.connectToExistingConnection since the pg connection comes from a pool.

In my setup, pg cannot be resolved so the var pg=require('pg')line breaks everything.

This PR uses require.resolve() in a try/catch block to discover if pg module can be resolved or not.

The require is only done if pg can be resolved.

Note that I used the 2 steps resolve/require in order to not put the require inside the try/catch block since code inside try/catch blocks cannot be optimized by V8.

Hope this helps.

ps: I am sorry I did not write a test for this and understand that this is not a perfect PR according to your standards. My setup uses node v0.11.9 and I could not even do npm install after cloning db-meta.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant