1 var fs = require( 'graceful-fs' );
2 var write = require( 'write' );
3 var circularJson = require( 'circular-json' );
7 tryParse: function ( filePath, defaultValue ) {
10 result = this.readJSON( filePath );
12 result = defaultValue;
18 * Read json file synchronously using circular-json
21 * @param {String} filePath Json filepath
22 * @returns {*} parse result
24 readJSON: function ( filePath ) {
25 return circularJson.parse( fs.readFileSync( filePath ).toString() );
29 * Write json file synchronously using circular-json
32 * @param {String} filePath Json filepath
33 * @param {*} data Object to serialize
35 writeJSON: function ( filePath, data ) {
36 write.sync( filePath, circularJson.stringify( data ) );