Skip to content

Instantly share code, notes, and snippets.

@kirkdotcam
Created March 27, 2018 02:41
Show Gist options
  • Save kirkdotcam/1d01fae0a1318b71695c382f055aa91d to your computer and use it in GitHub Desktop.
Save kirkdotcam/1d01fae0a1318b71695c382f055aa91d to your computer and use it in GitHub Desktop.
fs.readdirSync(collecDirectory)
.forEach((filename) => {
let nameArray = filename.split('.')
if (nameArray[nameArray.length-1]==='json'){
let tmp = require(path.join('../../'+collecDirectory,nameArray[0]))
if(typeof tmp === "array"||typeof tmp ==="object"){
let tempName = nameArray[0].charAt(0).toUpperCase() + nameArray[0].slice(1)
global[tempName] = new Model(tempName,path.join(collecDirectory,filename),tmp)
collecNames.push(filename)
}
}
else{return}
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment