Created
July 28, 2015 11:03
-
-
Save foxx/006ec0ff7324af7a9eb6 to your computer and use it in GitHub Desktop.
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
(function() { | |
var fs = require('fs'); | |
var path = require('path'); | |
var current_dir = path.dirname(fs.realpathSync(__filename)); | |
var design_docs_dir = path.join(current_dir, 'design_docs'); | |
var files = fs.readdirSync(design_docs_dir); | |
var json = {}; | |
files.forEach(function(fpath) { | |
fpath = path.join(design_docs_dir, fpath); | |
var o = require(fpath); | |
var doc_name = path.basename(fpath, '.js'); | |
json[doc_name] = {}; | |
Object.keys(o).forEach(function(key) { | |
var map_func = (o[key]['map'] ? o[key]['map'].toString() : null); | |
var reduce_func = (o[key]['reduce'] ? o[key]['reduce'].toString() : null); | |
var obj = {map: map_func, reduce: reduce_func}; | |
json[doc_name][key] = obj; | |
}); | |
}); | |
console.log(JSON.stringify(json, null, 2)); | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment