File tree 1 file changed +15
-6
lines changed
1 file changed +15
-6
lines changed Original file line number Diff line number Diff line change @@ -39,10 +39,19 @@ jsome.level.spaces = argv.s;
39
39
40
40
var filePath = argv . _ [ 0 ] || '' ;
41
41
42
- fs . exists ( path . resolve ( filePath ) , function ( exists ) {
43
- if ( ! exists ) return jsome ( { error : "File doesn't exists" } ) ;
44
- fs . readFile ( path . resolve ( filePath ) , function ( error , jsonString ) {
45
- if ( error ) return jsome ( { error : error . message } ) ;
46
- jsome . parse ( jsonString . toString ( ) ) ;
42
+ if ( filePath ) {
43
+ fs . exists ( path . resolve ( filePath ) , function ( exists ) {
44
+ if ( ! exists ) return jsome ( { error : "File doesn't exist" } ) ;
45
+ fs . readFile ( path . resolve ( filePath ) , function ( error , jsonString ) {
46
+ if ( error ) return jsome ( { error : error . message } ) ;
47
+ jsome . parse ( jsonString . toString ( ) ) ;
48
+ } ) ;
47
49
} ) ;
48
- } ) ;
50
+ } else {
51
+ process . stdin . resume ( ) ;
52
+ process . stdin . setEncoding ( 'utf8' ) ;
53
+
54
+ process . stdin . on ( 'data' , function ( data ) {
55
+ jsome ( JSON . parse ( data ) ) ;
56
+ } ) ;
57
+ }
You can’t perform that action at this time.
0 commit comments