broccoli-tree-to-json
Roll up a directory tree into a JSON document.
The directory structure:
root
|--key1.txt #123
|--key2.txt #val2
+--subdir
|--key3.txt #true
|--key4.txt #val4
Will result in the following json:
//destDir/root.json "key1":123 "key2":"val2" "subdir": "key3":true "key4":"val4"
The file extension is ignored. The JSON key is determined by the portion of the file to the left of the first dot.
File contents are parsed by JSON.parse
, and if that fails the contents of the file is treated like a string.
TODO
- Better Array support
Example use
In a Brocfile:
//Brocfile.jsvar tree2Json = ; moduleexports = ;
Within another plugin
//index.jsvar tree2Json = path = ; { thisjsonTree = ;} MyPluginprototype{ return ;}; moduleexports = MyPlugin;