Skip to content

Instantly share code, notes, and snippets.

@yusufiga
Created December 9, 2015 19:16
Show Gist options
  • Save yusufiga/3fed0690e2aee3ca3cf4 to your computer and use it in GitHub Desktop.
Save yusufiga/3fed0690e2aee3ca3cf4 to your computer and use it in GitHub Desktop.
Get Deployd Collections
var dirTree = require('directory-tree');
console.log(getCollections());
function getCollections (){
var tree = dirTree.directoryTree('resources/',['.json']);
var collections = collections || [];
console.log(tree.children);
for (var i in tree.children) {
var obj = {};
//var data = tree.children[i].
var structure = require("./resources/"+tree.children[i].children[0].path);
obj[tree.children[i].name] = structure.properties ;
collections.push(obj);
}
return collections;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment