let fs = require("fs") let getreptilelist =(dirlist)=>{ return new Promise((res,err)=>{ let reptilelist = []; // console.log(dirlist) for(let i in dirlist){ let reptile = require(__dirname + "/" + dirlist[i] +"/config.js" ) // console.log(reptile) reptilelist.push(reptile) } res(reptilelist) }) } getlist =()=>{ return new Promise((r,e)=>{ fs.readdir(__dirname, (err, res) => { for (let i in res) { if (res[i] == "binimport.js") { res.splice(i, 1) } } dirlist = res // console.log(res) getreptilelist(dirlist).then((s)=>{ r(s) }) }) }) } module.exports = getlist