Skip to content

Commit e352ae8

Browse files
committed
Expose package.json as mysql.PACKAGE
Fixes mysqljs#104
1 parent 9cb64cd commit e352ae8

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed

lib/mysql.js

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,15 @@
1+
var mysql = exports;
12
var hashish = require('hashish');
23
var Client = exports.Client = require('./client');
34
var constants = require('./constants');
5+
var fs = require('fs');
46

5-
exports.createClient = function(config) {
7+
mysql.PACKAGE = (function() {
8+
var json = fs.readFileSync(__dirname + '/../package.json', 'utf8');
9+
return JSON.parse(json);
10+
})();
11+
12+
mysql.createClient = function(config) {
613
var client = new Client();
714
hashish.update(client, config || {});
815
return client;

test/fast/test-mysql.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
var common = require('../common');
2+
var assert = require('assert');
3+
var test = common.fastOrSlow.fast();
4+
var mysql = require(common.dir.lib + '/mysql');
5+
6+
test('Package JSON is exported', function() {
7+
assert.strictEqual(mysql.PACKAGE.name, 'mysql');
8+
});

0 commit comments

Comments
 (0)