2 * file.js: Simple utilities for working with the file system.
4 * (C) 2011, Nodejitsu Inc.
9 var fs = require('fs');
11 exports.readJson = exports.readJSON = function (file, callback) {
12 if (typeof callback !== 'function') {
13 throw new Error('utile.file.readJson needs a callback');
16 fs.readFile(file, 'utf-8', function (err, data) {
22 var json = JSON.parse(data);
31 exports.readJsonSync = exports.readJSONSync = function (file) {
32 return JSON.parse(fs.readFileSync(file, 'utf-8'));