How can I get all the js files that are inside of folder, and that folder is inside of another folder?
I'm very new to JS, and I know I can get it using readdirSync
but I can only get all the files in the current directory.
fs
.readdirSync(__dirname)
.filter(file => {
return (file.indexOf('.') !== 0) && (file !== basename) && (file.slice(-3) === '.js');
})
.forEach(file => {
console.log(file + "✅");
const model = sequelize['import'](path.join(__dirname, file));
db[model.name] = model;
});
Here's my file structure.