mysqljs / mysql

A pure node.js JavaScript Client implementing the MySQL protocol.
MIT License
18.3k stars 2.52k forks source link

Support environments that cannot require json files #959

Closed LorenzGardner closed 9 years ago

LorenzGardner commented 9 years ago

https://github.com/felixge/node-mysql/blob/master/lib/ConnectionConfig.js#L127

   SSLProfiles = require('./../fixtures/ssl-profiles.json');

Not all environments support json files with the require (specifically nexe).

The usage seems weird to me, I guess it has been in node for a while (since 2011) but I would like to change the line to

  SSLProfile = JSON.parse(fs.readFileSync('./../fixtures/ssl-profiles.json'));

You may note this is indeed the implementation of require for JSON files: https://github.com/joyent/node/commit/588d885e81dec667920383ac7246daceeb7f99fd

dougwilson commented 9 years ago

What is nexe? Can you link me up?

dougwilson commented 9 years ago

Nevermind, the repo is in your public activity :)

dougwilson commented 9 years ago

Can you verify that the change you are proposing will actually work with nexe? I'm looking around in it and I'm not 100% sure that it understands fs either...

LorenzGardner commented 9 years ago

Yes, it does understand fs.

I did the proposed change on my local HD and it works.

dougwilson commented 9 years ago

Great :)

LorenzGardner commented 9 years ago

I've modified nexe to support JSON require.

dougwilson commented 9 years ago

Neat :) Though I'm still going to move that into a .js file for 2.6 since it'll be more maintainable since I can make the certificate multiple lines instead of one enormous line :)