File tree Expand file tree Collapse file tree 1 file changed +11
-5
lines changed Expand file tree Collapse file tree 1 file changed +11
-5
lines changed Original file line number Diff line number Diff line change @@ -24,8 +24,11 @@ function init(cfg) {
24
24
} ;
25
25
26
26
if ( cfg . reader . columns ) {
27
- console . log ( 'Configured columns:' , cfg . reader . columns ) ;
28
- options . columns = cfg . reader . columns ;
27
+
28
+ const columns = Object . keys ( _ . keyBy ( cfg . reader . columns , 'property' ) ) ;
29
+
30
+ console . log ( 'Configured column names:' , columns ) ;
31
+ options . columns = columns ;
29
32
}
30
33
31
34
stringifier = csv . stringify ( options ) ;
@@ -66,12 +69,15 @@ function processAction(msg, cfg) {
66
69
console . log ( 'Emitting message %j' , messageToEmit ) ;
67
70
self . emit ( 'data' , messageToEmit ) ;
68
71
69
- yield init ( ) ;
72
+ yield init ( cfg ) ;
70
73
} ) ;
71
74
} , 10000 ) ;
72
75
73
- const columns = cfg . reader . columns ;
74
- const row = columns ? _ . pick ( msg . body , columns ) : msg . body ;
76
+ let row = msg . body ;
77
+ if ( cfg . reader . columns ) {
78
+ const columns = Object . keys ( _ . keyBy ( cfg . reader . columns , 'property' ) ) ;
79
+ row = _ . pick ( msg . body , columns ) ;
80
+ }
75
81
stringifier . write ( row ) ;
76
82
rowCount ++ ;
77
83
this . emit ( 'end' ) ;
You can’t perform that action at this time.
0 commit comments