File tree Expand file tree Collapse file tree 1 file changed +12
-6
lines changed Expand file tree Collapse file tree 1 file changed +12
-6
lines changed Original file line number Diff line number Diff line change @@ -12,10 +12,16 @@ const fs = require('fs');
1212 * @param {Hash } opts - All options
1313 */
1414module . exports = function ( opts ) {
15- const file = path . resolve ( opts . target , 'eo-foreign.json' ) ,
16- all = JSON . parse ( fs . readFileSync ( file , 'utf8' ) ) ;
17- console . info ( 'There are %d objects in %s:' , all . length , rel ( file ) ) ;
18- all . forEach ( ( obj ) => {
19- console . info ( ' %s' , obj . id ) ;
20- } ) ;
15+ const file = path . resolve ( opts . target , 'eo-foreign.json' ) ;
16+ try {
17+ let content = fs . readFileSync ( file , "utf8" ) ;
18+ content = content . replace ( / \r \n / g, "\n" ) . replace ( / \r / g, "\n" ) ;
19+ const all = JSON . parse ( content ) ;
20+ console . info ( 'There are %d objects in %s:' , all . length , rel ( file ) ) ;
21+ all . forEach ( ( obj ) => {
22+ console . info ( ' %s' , obj . id ) ;
23+ } ) ;
24+ } catch ( error ) {
25+ throw new Error ( `Parsing a document fails:` , error ) ;
26+ }
2127} ;
You can’t perform that action at this time.
0 commit comments