@@ -11,12 +11,14 @@ var Validators = require("./Validators");
1111var Settings = require ( "./Settings" ) ;
1212var Singleton = require ( "./Singleton" ) ;
1313var ErrorCodes = require ( "./ErrorCodes" ) ;
14+ var Utilities = require ( "./Utilities" ) ;
1415
1516exports . validators = Validators ;
1617exports . singleton = Singleton ;
1718exports . settings = new Settings . Container ( Settings . defaults ( ) ) ;
18- exports . Settings = Settings ;
19+
1920exports . Property = require ( "./Property" ) ;
21+ exports . Settings = Settings ;
2022exports . ErrorCodes = ErrorCodes ;
2123
2224exports . Text = Query . Text ;
@@ -161,7 +163,11 @@ util.inherits(ORM, events.EventEmitter);
161163
162164ORM . prototype . use = function ( plugin_const , opts ) {
163165 if ( typeof plugin_const == "string" ) {
164- plugin_const = require ( plugin_const ) ;
166+ try {
167+ plugin_const = require ( Utilities . getRealPath ( plugin_const ) ) ;
168+ } catch ( e ) {
169+ throw e ;
170+ }
165171 }
166172
167173 var plugin = new plugin_const ( this , opts || { } ) ;
@@ -219,27 +225,8 @@ ORM.prototype.close = function (cb) {
219225 return this ;
220226} ;
221227ORM . prototype . load = function ( file , cb ) {
222- var cwd = process . cwd ( ) ;
223- var err = new Error ( ) ;
224- var tmp = err . stack . split ( / \r ? \n / ) [ 2 ] , m ;
225-
226- if ( ( m = tmp . match ( / ^ \s * a t \s + ( .+ ) : \d + : \d + $ / ) ) !== null ) {
227- cwd = path . dirname ( m [ 1 ] ) ;
228- } else if ( ( m = tmp . match ( / ^ \s * a t \s + m o d u l e \. e x p o r t s \s + \( ( .+ ?) \) / ) ) !== null ) {
229- cwd = path . dirname ( m [ 1 ] ) ;
230- } else if ( ( m = tmp . match ( / ^ \s * a t \s + .+ \s + \( ( .+ ) : \d + : \d + \) $ / ) ) !== null ) {
231- cwd = path . dirname ( m [ 1 ] ) ;
232- }
233-
234- if ( file [ 0 ] != path . sep ) {
235- file = cwd + "/" + file ;
236- }
237- if ( file . substr ( - 1 ) == path . sep ) {
238- file += "index" ;
239- }
240-
241228 try {
242- return require ( file ) ( this , cb ) ;
229+ return require ( Utilities . getRealPath ( file ) ) ( this , cb ) ;
243230 } catch ( ex ) {
244231 return cb ( ex ) ;
245232 }
0 commit comments