Skip to content

Instantly share code, notes, and snippets.

@cowboy
Created June 5, 2012 16:36
Show Gist options
  • Select an option

  • Save cowboy/2876125 to your computer and use it in GitHub Desktop.

Select an option

Save cowboy/2876125 to your computer and use it in GitHub Desktop.
Grunt: readOptionalJSON
'use strict';
module.exports = function(grunt) {
function readOptionalJSON(filepath) {
var data = {};
try {
data = grunt.file.readJSON(filepath);
grunt.log.write('Reading data from ' + filepath + '...').ok();
} catch(e) {}
return data;
}
// Project configuration.
grunt.initConfig({
foo: readOptionalJSON('foo.json')
});
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment