File tree 1 file changed +16
-21
lines changed
1 file changed +16
-21
lines changed Original file line number Diff line number Diff line change 6
6
*
7
7
*/
8
8
9
- var fs = require ( 'fs' ) ,
10
- path = require ( 'path' ) ,
11
- common = require ( './common' ) ;
12
-
13
- var transports = exports ;
9
+ var path = require ( 'path' ) ;
14
10
15
11
//
16
12
// Setup all transports as lazy-loaded getters.
17
13
//
18
- fs . readdirSync ( path . join ( __dirname , 'transports' ) ) . forEach ( function ( file ) {
19
- var transport = file . replace ( '.js' , '' ) ,
20
- name = common . capitalize ( transport ) ;
21
-
22
- if ( transport === 'transport' ) {
23
- return ;
24
- }
25
- else if ( ~ transport . indexOf ( '-' ) ) {
26
- name = transport . split ( '-' ) . map ( function ( part ) {
27
- return common . capitalize ( part ) ;
28
- } ) . join ( '' ) ;
29
- }
14
+ Object . defineProperties (
15
+ exports ,
16
+ [ 'Console' , 'File' , 'Http' , 'Memory' ]
17
+ . reduce ( function ( acc , name ) {
18
+ acc [ name ] = {
19
+ configurable : true ,
20
+ enumerable : true ,
21
+ get : function ( ) {
22
+ var fullpath = path . join ( __dirname , 'transports' , name ) ;
23
+ return exports [ name ] = require ( fullpath ) [ name ] ;
24
+ }
25
+ } ;
30
26
31
- transports . __defineGetter__ ( name , function ( ) {
32
- return require ( './transports/' + transport ) [ name ] ;
33
- } ) ;
34
- } ) ;
27
+ return acc ;
28
+ } , { } )
29
+ ) ;
You can’t perform that action at this time.
0 commit comments