mirror of
				https://github.com/knex/knex.git
				synced 2025-11-03 19:29:42 +00:00 
			
		
		
		
	Inherit knex instance VERSION property from constructor
This commit is contained in:
		
							parent
							
								
									46b686b4f0
								
							
						
					
					
						commit
						6cbceefdb8
					
				@ -8,6 +8,7 @@ import QueryInterface from '../query/methods';
 | 
			
		||||
import * as helpers from '../helpers';
 | 
			
		||||
import { assign } from 'lodash'
 | 
			
		||||
import BatchInsert from './batchInsert';
 | 
			
		||||
import Knex from "../index";
 | 
			
		||||
 | 
			
		||||
export default function makeKnex(client) {
 | 
			
		||||
 | 
			
		||||
@ -57,7 +58,7 @@ export default function makeKnex(client) {
 | 
			
		||||
 | 
			
		||||
  // The `__knex__` is used if you need to duck-type check whether this
 | 
			
		||||
  // is a knex builder, without a full on `instanceof` check.
 | 
			
		||||
  knex.VERSION = knex.__knex__ = require('../../package.json').version;
 | 
			
		||||
  knex.VERSION = knex.__knex__ = Knex.VERSION;
 | 
			
		||||
 | 
			
		||||
  // Hook up the "knex" object as an EventEmitter.
 | 
			
		||||
  const ee = new EventEmitter()
 | 
			
		||||
 | 
			
		||||
@ -3,6 +3,18 @@
 | 
			
		||||
var knex = require('../../lib/index');
 | 
			
		||||
var test = require('tape')
 | 
			
		||||
 | 
			
		||||
test('it should have the same version as constructor has', function(t) {
 | 
			
		||||
  t.plan(1)
 | 
			
		||||
  var knexObj = knex({
 | 
			
		||||
    database: 'dbname',
 | 
			
		||||
    host: 'example.com',
 | 
			
		||||
    password: 'password',
 | 
			
		||||
    user: 'user'
 | 
			
		||||
  })
 | 
			
		||||
  t.equal(knexObj.VERSION, knex.VERSION)
 | 
			
		||||
  knexObj.destroy()
 | 
			
		||||
})
 | 
			
		||||
 | 
			
		||||
test('it should parse the connection string', function(t) {
 | 
			
		||||
  t.plan(1)
 | 
			
		||||
  var knexObj = knex({
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user