Grunt task to traverse a folder and flatten it to a JSON representation. Previously existed as grunt-dir2json (grunt-spelunk extracts the core functionality into a separate module - spelunk - and improves performance).
See the spelunk docs for an introduction.
This plugin requires Grunt
If you haven't used Grunt before, be sure to check out the Getting Started guide, as it explains how to create a Gruntfile as well as install and use Grunt plugins. Once you're familiar with that process, you may install this plugin with this command:
npm install grunt-spelunk --save-dev
The "spelunk" task
In your project's Gruntfile, add a section named
spelunk to the data object passed into
A pattern, or array of patterns, of filenames to exclude, e.g.
**/README.md. Uses the standard globbing syntax.
Thumbs.db files will always be excluded - you don't need to specify these.
Transforms values and properties when stringifying JSON. See the MDN docs
Pretty-prints the result using this string. See the MDN docs
If supplied, spelunk will create JSONP instead of JSON (note that the destination filename should end
.js and not
.json in this case)
true, spelunk will create an AMD module (as above, extension should be
This will read the contents of
project/data and write a JSON file representing its contents to
project/src/data.json, excluding any README files:
In lieu of a formal styleguide, take care to maintain the existing coding style. Add unit tests for any new or changed functionality. Lint and test your code using Grunt.