Created
June 5, 2012 16:36
-
-
Save cowboy/2876125 to your computer and use it in GitHub Desktop.
Grunt: readOptionalJSON
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| '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