File tree 1 file changed +19
-9
lines changed
1 file changed +19
-9
lines changed Original file line number Diff line number Diff line change @@ -51,16 +51,28 @@ function getFields(callback) {
51
51
}
52
52
53
53
function getInput ( callback ) {
54
- var input , isAbsolute , rows ;
54
+ var input = '' ;
55
55
56
56
if ( program . input ) {
57
- isAbsolute = isAbsolutePath ( program . input ) ;
58
- input = require ( isAbsolute ? program . input : path . join ( process . cwd ( ) , program . input ) ) ;
57
+ var isAbsolute = isAbsolutePath ( program . input ) ;
58
+ var inputPath = isAbsolute ? program . input : path . join ( process . cwd ( ) , program . input ) ;
59
59
60
+ if ( program . ldjson ) {
61
+ fs . readFile ( inputPath , 'utf8' , function ( err , data ) {
62
+ if ( err ) {
63
+ return callback ( err ) ;
64
+ }
65
+
66
+ input = parseLdJson ( data ) ;
67
+ callback ( null , input ) ;
68
+ } ) ;
69
+ return ;
70
+ }
71
+
72
+ input = require ( inputPath ) ;
60
73
return callback ( null , input ) ;
61
74
}
62
75
63
- input = '' ;
64
76
process . stdin . resume ( ) ;
65
77
process . stdin . setEncoding ( 'utf8' ) ;
66
78
@@ -71,11 +83,9 @@ function getInput(callback) {
71
83
debug ( 'Could not read from stdin' , err ) ;
72
84
} ) ;
73
85
process . stdin . on ( 'end' , function ( ) {
74
- if ( program . ldjson ) {
75
- rows = parseLdJson ( input ) ;
76
- } else {
77
- rows = JSON . parse ( input ) ;
78
- }
86
+ var rows = program . ldjson
87
+ ? parseLdJson ( input )
88
+ : JSON . parse ( input ) ;
79
89
80
90
callback ( null , rows ) ;
81
91
} ) ;
You can’t perform that action at this time.
0 commit comments